@the-/scope
State scope for the-store
Installation
$ npm install @the-/scope --save
Usage
'use strict'
const { TheScope } = require('@the-/scope')
const { TheStore } = require('@the-/store')
async function tryExample() {
class FlgScope extends TheScope {
static get initialState() {
return false
}
static get reducerFactories() {
return {
toggle(value) {
return (state) => (typeof value === 'undefined' ? !state : value)
},
}
}
}
const store = new TheStore()
store.load(FlgScope, 'flg')
store.flg.toggle(true)
console.log(store.flg.state) // -> true
}
tryExample().catch((err) => console.error(err))
API Guide
- BooleanScope
- module:@the-/scope
- module:@the-/scope.scopes
- module:@the-/scope.scopes.ArrayScope
- module:@the-/scope.scopes.BooleanScope
- module:@the-/scope.scopes.NullScope
- module:@the-/scope.scopes.NumberScope
- module:@the-/scope.scopes.ObjectScope
- module:@the-/scope.scopes.StringScope
- module:@the-/scope.scopes.ValueScope
- NumberScope
- ObjectScope
- Scope
- ScopeScope
See API Guide for more detail
License
This software is released under the MIT License.