@clutch-marketplace/statehub

0.0.5 • Public • Published

A group of context state data.

All properties created on this component will spread a value and a change function to its all descendants.

Ex: A 'mainColor' property will be shared as 'mainColor' and 'setMainColor' values to be used by any descendants on Expressions Controls.

The value set on the property panel is used as the initial value.

Using

  1. Create a property on this component to create a state key
  2. Define a value on the property to be the state initial value
  3. Use a Expression Control on any descendant property to consume this state value
  4. Use a Expression Control on any descendant property to consume the function to change this state value

Stacking State Hubs

This component also connects itself with any State Hub component descendant, even inside another component. To manage that you must define a 'contextName' property on it, and all values of this State Hub will be shared grouped on a single object on the State Hub descendants.

Change Events

This component also shares events functions to be used on Module Controls to sideeffects on state changes.

  1. onChange - called when any state changes
  2. on{Property name}Change - called when on state changes. Eg. onExampleChange - be called the the setExample is called any where.
/*
 * update - update state values
 * value - current changed new value
 * key - current changed state (property) name
 * state - all state properties
 * onChange - call a exposed onChange function
 * moduleArgs - other values passed to this property on property children array
 */

export default (update, value, key, state, ...moduleArgs) => {};

Readme

Keywords

none

Package Sidebar

Install

npm i @clutch-marketplace/statehub

Weekly Downloads

2

Version

0.0.5

License

none

Unpacked Size

344 kB

Total Files

25

Last publish

Collaborators

  • clutch-bot