Stateful Store
Developer Use
Currently the main API methods are:
const LspiFlux = const lf = // this will make an LspiFlux object with the following defaults// LspiFlux {storeName: "lspi-flux", mainStore: {}} lffetchState // if all goes well this will return {status: true, state: {}} ->lffetchStatestate // {}lffetchStatestatus // true // if localStorage fails, this will return the state in memory before writing to localStorage// it will also return a 'status' of false to help handle errors const someObject = wow: "wow"lf // this will return the same object as fetchState // but the state here will be updated if nothing went wrong// otherwise, handle the error by checking for a flase status // if all goes well this will return {status: true, state: {wow: "wow"}} ->lfstate // {wow: "wow"}lfstatus // true // say you want to name the store and set a default value yourself ->const ideas = {} 'ideas' ideas /***whereState will return an object with two keys status: match: this does not return the objects stateinstead it returns the match of objects wrapped in an array if there are any***/ // ->const okResult = ideasconst okMatch = okResultmatch okResultstate // trueokResultmatch // [{wow: "ok"}, {wow: "ok"}]// okMatch -> [{wow: "ok"}, {wow: "ok"}] const nopeResult = ideasconst nopeMatch = nopeResultmatch nopeResultstate // truenopeResultmatch // [{wow: "nope"}]// nopeMatch -> [{wow: "nope"}] // this is all that this library offers for the moment// but a lot can be done to handle state with these three simple methods // Enjoy!
Current tests
Contributor Setup
Go to either: https://github.com/selfup/lspi-flux
Or: https://gitlab.com/selfup/lspi-flux
Clone one of them and:
npm install
To run the tests:
npm start
Then go to: http://localhost:8080/webpack-dev-server/test.html
TODO
- Write more Documentation
- Ask for feedback about the API