Closed iofjuupasli closed 7 years ago
Yeah. I agree that StoreMethods
doesn't need to be a "defaults" object. It should mix itself in, and merge function calls. Unless anyone objects I can't see why we shouldn't have this changed.
Am in agreement!
Would be great!
With the ES6 patterns this is not very relevant any more. Closing unless someone thinks there's a good reason to pursue it.
it logs only
local
to console. But I expected both,global
andlocal
The problem is here: https://github.com/spoike/refluxjs/blob/master/src/createStore.js#L55 It overrides methods fromReflux.StoreMethods
with methods fromdefinition
Reflux.StoreMethods
is like defaults fordefinition
. But It's unobvious. For comparison, in mixins bothinit
will call. As it works in React for livecycle methods (e.g.componentWillMount
,getInitialState
). So, maybe it'll be better ifReflux.StoreMethods
will works as global mixin rather than defenition defaultsFor example it can be helpful for hydrate stores in it's
init
method. Just for example, something like:Or using for hook into
preEmit
orshouldEmit
for some reason. One another issue here, is only one possible global method. What if we have two separated modules, that useinit
method in all stores.Second assignment will override first. Instead it'll be better to use method for adding new functionality:
That looks like mixin for all stores:
As we already have mixins, probably this feature will not greatly increase code size.