Using npm:
npm install temperjs-store
Using yarn:
yarn add temperjs-store
Temper Store is a state container for JavaScript apps.
// using ES6 modules
import { storeActions } from 'temperjs-store'
// using CommonJS modules
const storeActions = require('temperjs-store').storeActions
storeActions.setTrait('traitPath', 'traitValue')
Temper Store exports an object with the following interface (more details on each action below):
interface StoreActions = {
create(options?: StoreOptions): void
getTrait<T>(path: string): T | undefined
setTrait<T>(path: string, traitValue: SetterValue<T>): void
subscribeToTrait<T>(
path: string,
callback: (traitValue: T | undefined) => void,
defaultValue?: T
): Subscription | undefined
destroy(): void
}
Creates the global store object.
Returns the value of a Trait. Traits are globally shared units of state that components can subscribe to.
Sets the value of a Trait.
Subscribes a callback to a Trait and returns a Subscription
object
Destroys the store.