tamb / substate Goto Github PK
View Code? Open in Web Editor NEWpub/sub state management with optional deep cloning
License: MIT License
pub/sub state management with optional deep cloning
License: MIT License
maybe just suggest encapsulating Actions and Event names within store?
store.register[x]()
store.registerMutations(Function | [Functions])
A mutation should return an object as new state,
This changes the call signature of emit
emit(String, {Function | Object})
store.registerActions
Show patterns of use:
substate action with payload describing new state
--> (state cloning magic)
--> callback(s) w/ new state
substate action with payload
--> reused logic to consume this action and describe new state
--> (state cloning magic)
--> callback(s) w/ new state
infinite actions, infinite data changes, infinite responses
A happens --> do B --> yields C for those who care
ABCD happens --> do E --> yields F for those who care
A happens --> do B2 --> yields C2 for those who care
ABCD happens --> do E2 --> yields F2 for those who care
etc...
changeState should revert the state to specified index and change currentState index.
Essentially a helper that will subscribe and unsubscribe right away???
Maybe functions should register like this:
{
cbFunc: function,
callCount: 0,
futureFields,
}
default param to { }
Would be good to add async support through:
dispatch
commit
I can implement those methods to call emit
under the hood.
We should implement this without breaking the current API.
__
the reasoning behind this is to support the goal of universal terminology in application state management. Sure it's a more convoluted pub/sub. But it should help teams to get on the same page.
Ala Vuex, I'd like to add module support.
https://vuex.vuejs.org/guide/modules.html
I need to write tests for the middleware functionality to make sure that the functions are fired in the right order.
You should be able to export individual instances of Substate and merge them into one for a shared set of stores.
Do NOT rely on a polyfill for a feature that doesn't exist. Switch to the byString
helper function from the newer version of the library
When you emit('UPDATE_STATE', {} )
, there should be a config option for middleware to access the entire state management instance.
Right before STATE_UPDATED
or a custom action is returned, there should option for middleware to fire. So it's a method that fires on EVERY state update.
This will allow for client side storage to be added, and other features.
Optional configs only for dev mode that will give helpful clues. Emit $type
and use colors like:
console.log('%c Oh my heavens! ', 'background: #222; color: #bada55');
This way you can track your messages
Eventually a library should be made
Perhaps this config also allows you to add your store to the window object
lodash dependency is big. Cut the size by finding a smaller deep clone util.
Consider the following state changes scenario
In the end, our state array will be ['foo', 'bar', 'fox', 'bump']
. Should it be ['foo', 'bar', 'bump']
instead?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.