@oframe/state v1.0.2
@oframe/state
Install
npm i @oframe/stateyarn add @oframe/stateimport { State } from './State.mjs';Documentation
@oframe/state is a singleton used to connect event listeners and emitters.
It creates a global emitter, exported under State, however users may instantiate multuple emitters from the exported StateClass class using the new keyword.
Emitter.data
Emitter.data adds a new callback to the desired name string. Emissions of the name string will trigger the callbacks in the same order that they're added. The callback will be stored until the Emitter.off() method is called using the same parameters.
Return value
Data.
Emitter.link()
Emitter.link() adds a new callback to the desired name string. Emissions of the name string will trigger the callbacks in the same order that they're added. The callback will be stored until the Emitter.off() method is called using the same parameters.
Syntax
void Emitter.link(props, callback)
Params
props
A String event name used as reference to callbacks from the Emitter.emit() method.
callback
A Function callback to be triggered when the Emitter.emit() function is called with a matching name.
Return value
None
Emitter.unlink()
Emitter.unlink() removes a callback from the desired name string. Further emissions of the name string will no longer trigger the callback.
Syntax
void Emitter.unlink(props, callback)
Params
props
A String event name used as reference to callbacks from the Emitter.emit() method.
callback
A Function callback to be triggered when the Emitter.emit() function is called with a matching name.
Return value
None
Emitter.push()
Emitter.push()
Syntax
void Emitter.push(data)
Params
dataoptional
An Object to be passed to the callback functions.
Return value
None