storeon-velo (master) doxdox documentation

A tiny event-based state manager Storeon for Velo by Wix

# ...args(args)

Connects to state by property key. It will return the function disconnect from the store.

Parameters

Name Types Description
args Connect properties keys and event listener.

# createStoreon(modules)

Initialize new store and apply all modules to the store. js import { createStoreon } from 'storeon-velo'; const app = (store) => { store.on('@init', () => ({ count: 0 })); store.on('inc', ({ count }) => ({ count: count + 1 })); }; const { getState, setState, dispatch, connect, readyStore } = createStoreon([app]);

Parameters

Name Types Description
modules Functions which will set initial state define reducer and subscribe to all system events.

# createStoreon.DispatchableEvents(event, data)

Emit event.

Parameters

Name Types Description
event The event name.
data Any additional data for the event.

# createStoreon.DispatchableEvents(event, data)

Emit event.

Parameters

Name Types Description
event The event name.
data Any additional data for the event.

# get()

Return current state. You can use this method only to read state. Any state changes should be in event listeners.

# getState()

Return current state. You can use this method only to read state. Any state changes should be in event listeners.

# keyof(event, handler)

Add event listener.

Parameters

Name Types Description
event The event name.
handler The event listener.

# set(data)

Set partial state. Accepts an object that will assign to the state. it can be useful for async event listeners.

Parameters

Name Types Description
data partial state object.

# setState(data)

Set partial state. Accepts an object that will assign to the state.

Parameters

Name Types Description
data Any additional data for the event.

# off()