shake(id)
Shakes a node to call all callback functions without changing node data.
Parameters
- id (string) - string id of a node.
Returns
- N/A
Examples
Tip 1:
shake
can be used to broadcast an action been triggered.
import Treeful from 'treeful';
Treeful.add('onClickButton');
Treeful.subscribe('onClickButton', onClickButton);
Treeful.shake('onClickButton');
function onClickButton() {
console.log('click!');
}
Tip 2:
shake
can also be used on nodes that do have data. In this case,shake
will be essentially same assetData
without changing the data.
import Treeful from 'treeful';
Treeful.add('n1', 1);
Treeful.subscribe('n1', callback);
Treeful.shake('n1');
function callback(data, node) {
// data = 1
// node = 'n1'
}