-
Notifications
You must be signed in to change notification settings - Fork 0
Dispatcher API
The TrebleGSM SubscribeAPI was introduced in V2 to access and manage state in the Store.
You can access the SubscribeAPI object with the useTreble hook.
const [StoreItems, StoreMethods] = useTreble();
This method is used to update a state value in the Store with a new value.
Store.update(action, dispatchValue, options?);
Update a single object in a state object array. Uses the trebleKey
property to find the object and replace it with the updated one. (Must have the Keys feature set to true in the Store)
Store.edit(action, updatedStateObject);
Targets a value in a Store state array and removes it.
Store.remove(action, targetValue);
Removes an array of values from a Store state array.
Store.removeBatch(action, targetBatch);
Appends a state value to a Store state array.
Store.append(action, dispatchValue, options?);
Prepends a state value to a Store state array.
Store.prepend(action: string, dispatchValue, options?);
Orders a target property in ascending or descending order.
Store.orderBy(action, targetProperty, orderType: 'asc' | 'desc');
Takes the current boolean state of a Store state object and toggles boolean values back and forth.
Store.toggle(action, currentState);
Takes a state action and then resets the store value to its initial value.
Store.reset(action);
Returns an array of all Store actions.
Store.getActions();
Returns an array of all Store state keys.
Store.getStateKeys();