MicroStore
micro store in es6 for client.
Motivation
I need micro store for learning some apps.
Getting Started
$ npm install micro-store
;
API
- defaults
- create
- update
- destroy
- get
- order
- where
- limit
- dispatchChange
- dispatchCustomEvent
- addChangeListener
- removeChangeListener
- addCustomEventListener
- removeCustomEventListener
- register
- setData
- getData
Options
let options = localStorage: ture // bool(default: true); options;
Example
if you use event emitter, I prepared MicroEmitter for this. Recommnd: MicroEmitter
;; let AppDispatcher = ; // singleton { super; thisdefaults = text: '' completed: false ; this; } ; { thistodos = TodoStore; // when TodoStore updated, call this. TodoStore; // when TodoStore emit custom event(ex: PASS_VALIDATION), call this. TodoStore; } { const isCreatModalShowing = TodoStore; if isCreatModalShowing this; } /* ... */ { TodoStore; // if you don't use actions or dispatcher TodoStore; // if you use action or dispatcher AppDispatcher; }
TodoStore; // get all dataTodoStore; // get an itemTodoStore;TodoStore; // reverseTodoStore;TodoStore;TodoStore;