Skip to content

Latest commit

 

History

History
30 lines (22 loc) · 625 Bytes

README.md

File metadata and controls

30 lines (22 loc) · 625 Bytes

statehook.js

A state hook.

Installation

$ npm install statehook

API


StateHook.createHook([defaultValue])

Create a hook

var hook = StateHook.createHook();
// or
var hook = StateHook.createHook('default value');

hook.setState(newState) => newState

hook.getState() => any

hook.subscribe(subscriber) => unsubcribe()

hook.dispatch(args1, arg2, ..., argN) => void

hook.discard() => void

hook.isDiscarded() =>Boolean