You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I actually think what I want is for a way to create a Store class/factory, that can be either invoked or new'ed to create store instances. Perhaps a createStoreClass function, or maybe something like:
classMyStoreextendsSimpleStore{staticstoreFn(state,actions,dependencies,resolve){// store logic }}
...I think maybe I'd prefer the createStoreClass because then it could be used without new.
So then, I want a createStoreHook() function that is able to take either an instance, or Class/Factory, and maybe even just a function like createSimpleStoreHook() does now.
Because of the way it separates the shared store (from Provider) and the default context store, an instance of store needs to be able clone itself to be shared. I suppose the easiest way would be to have an instance have instance.constructor point to the class created from createStoreClass which should be use internally.
Hmm.... might need to think about this but, proposing the API right now:
createSimpleStore(storeFn) returns a store instance SimpleStore(storeFn) returns a class/factory function class MyStore extends Store creates a class that creates proxy based store instances**
createStoreHook( StoreClass / store / storeFn , options) creates a React hook, if a store instance is passed, the Provider will create a new store instance from store.constructor
(which feels odd but is probably the minority case anyway)
createStoreHook() returns a "useStore" style React hook which looks like useStore(stateSelector[, deps = []]) => [state, dispatch]
I actually think what I want is for a way to create a
Store
class/factory, that can be either invoked ornew
'ed to create store instances. Perhaps acreateStoreClass
function, or maybe something like:...I think maybe I'd prefer the
createStoreClass
because then it could be used without new.So then, I want a
createStoreHook()
function that is able to take either an instance, or Class/Factory, and maybe even just a function likecreateSimpleStoreHook()
does now.Because of the way it separates the shared store (from
Provider
) and the default context store, an instance of store needs to be able clone itself to be shared. I suppose the easiest way would be to have an instance haveinstance.constructor
point to the class created fromcreateStoreClass
which should be use internally.Hmm.... might need to think about this but, proposing the API right now:
createSimpleStore(storeFn)
returns a store instanceSimpleStore(storeFn)
returns a class/factory functionclass MyStore extends Store
creates a class that creates proxy based store instances**createStoreHook( StoreClass / store / storeFn , options)
creates a React hook, if a store instance is passed, theProvider
will create a new store instance fromstore.constructor
(which feels odd but is probably the minority case anyway)
createStoreHook()
returns a "useStore
" style React hook which looks likeuseStore(stateSelector[, deps = []]) => [state, dispatch]
** new upcoming feature
The text was updated successfully, but these errors were encountered: