Class: ManagedManager

olympe.dc.ranking. ManagedManager

"Managed" ranking manager The idea of this ranking manager is that the order of the items is defined externaly and is provided to via the #handleIndexes method.

The handleIndexes method accepts an array of ordered item indexes, a start and end number to allow the specification of a subset of the provided indexes and a callback that will be called for each new or removed item between two subsequent handleIndexes calls.

The method handleItem(...) will return a Deferred rank that will be passed to the following transformers. The Deferred instance will be distinct for each item. So the ManagedManager can be understood like a query with multiple base tags, for example an union transformer collect all the instances from the query it joins together, and pass each instance to the following transform chain.


new ManagedManager()

Implements:

Methods


activateDepth(depth)

Activate the ranking manager for the specified depth

Parameters:
Name Type Description
depth number
Implements:
Throws:

If the manager has already been activated

Type
Error

handleIndexes(orderedIndexes, start, end, callback)

Handles sorted indexes. This method is the core of this manager, it is responsible to detect added or removed items between multiple calls and will execute the callback accordingly.

Parameters:
Name Type Description
orderedIndexes Array.<string>

Array of indexes

start number

Position of the first index to process

end number

Position of the last index to process

callback olympe.dc.Manager.TransformationCallback

handleItem(added, tag, index [, value])

Handles an item (registers or unregisters it) that must be ranked.

This method returns a Deferred ranking object. This object will be passed to the following transformers like Related and Filter (but not Sort transformer), to handle the addition of new items (in case of relation) or removal of the item (in case of filtering)

Parameters:
Name Type Argument Description
added boolean

Whether the item is added or removed

tag string

Item's tag

index string

Item's index

value * <optional>

A value associated to the item, that can be used to sort it.

Implements:
Returns:
Type
olympe.dc.ranking.Deferred

isActivated()

Checks wether or not this manager has been activated

Implements:
Returns:
Type
boolean

setRanksUpdateHandler(callback)

Sets a function called whenever ranks are updated. The callback gets the ordered array of children indexes as argument.

Parameters:
Name Type Description
callback olympe.dc.ranking.Manager.RanksUpdateCallback
Implements:

updateActiveRanks()

Updates the ranks of all the items at the previously activated depth

Implements:
Throws:

If the manager has not been activated yet

Type
Error