useCollectors
useCollector()
#
#
Use ๐งA React hook that provides selectors to get information for a node by providing a query.
#
Signature ๐๏ธ#
Example Usage ๐#
Parameters ๐ฅselector: (selectors: Object) => chosen: Function
A function that takes the available selectors in an object with the selector functions as values as input, and should return one of the selector functions called with its respective parameter. (See example usage to understand better).
AVAILABLE SELECTORS
selectById (id: String) => selector: Function
Collect a node using its id.selectByIndex (name: String) => selector: Function
Collect a node related to a named index.selectRoot () => selector: Function
Collect root node.selectParent (id: String) => selector: Function
Collect parent of node using its id.selectByFilter (filter: Function) => selector: Function
Collect node using a function that iterates through all nodes and returns true whenever its finds a match.
caution
You should use some of the selectors, like selectParent with caution. Remember React's data flow, do not opt in for hacky solutions using a collector when there are better solutions using React best practices.
#
Return Value ๐คquery: Object
The query object that was collected by the specified selector.
It has the following keys:
node: Object
The collected node.
note
See Node for more information about nodes.
Example Usage:
meta: Object
An object with the metadata information for the collected node.
Example Usage:
indexes: Proxy
A proxy object with Boolean values depending on whether the id for the collected node is related to the named index used as the key for the indexes object.
Example Usage:
useMultiCollector()
#
A React hook that provides selectors to get information for a group node by providing a query.
#
Signature ๐๏ธ#
Example Usage ๐#
Parameters ๐ฅselector: (selectors: Object) => chosen: Function
A function that takes the available selectors in an object with the selector functions as values as input, and should return one of the selector functions called with its respective parameter. (See example usage to understand better).
AVAILABLE SELECTORS
selectMultipleById (...id: String) => selector: Function
Collect multiple node using their ids.selectMultipleByIndex (index: String) => selector: Function
Collect multiple node using a named index list.selectParents (id: String) => selector: Function
Collect all ancestors for node using its id.selectDirectChildren (id: String) => selector: Function
Collect direct descendant nodes using its id.selectChildren (id: String) => selector: Function
Collect all descendant nodes using its id.selectMultipleByFilter (filter: Function) => selector: Function
Collect multiple nodes using a function that iterates through all nodes and returns true whenever its finds a match.
caution
You should use some of the selectors, like selectParents with caution. Remember React's data flow, do not opt in for hacky solutions using a collector when there are better solutions using React best practices.
#
Return Value ๐คquery: Object
The query object that was collected by the specified selector.
It has the following keys:
nodes: Object
An object with the collected ids as keys and the collected nodes as values.
note
See Node for more information about nodes.
Example Usage:
meta: Object
An object with the collected ids as keys and the collected metadata for nodes as values.
Example Usage:
indexes: Object
An object with the collected ids as keys and proxy objects that have Boolean values depending on whether the id for the collected node is related to the named list index used as the key for the indexes object.
Example Usage:
listIds: () => [id: String]
A function that puts every collected id into an array.
Example Usage:
listNodes: () => [node: Object]
A function that puts every collected node into an array.
Example Usage:
listMeta: () => [meta: Object]
A function that puts every collected metadata into an array.
Example Usage: