fluxxor icon indicating copy to clipboard operation
fluxxor copied to clipboard

Allow Multiple StoreWatchMixins

Open sdemjanenko opened this issue 10 years ago • 3 comments

I would like to be able to do something like:

var TimeMixin = {
  mixins: [StoreWatchMixin("TimeStore")],
  ...
};

var List = React.createClass({
   mixins: [..., StoreWatchMixin("ArticleStore"), TimeMixin, ...],
});

Unfortunately StoreWatchMixin only allows itself to be mixed in once per component. I would have to do something like:

var List = React.createClass({
   mixins: [..., StoreWatchMixin("ArticleStore", "TimeStore"), TimeMixin, ...],
});

and not register the StoreWatchMixin in TimeMixin which seems less than ideal.

sdemjanenko avatar Feb 13 '15 20:02 sdemjanenko

Good catch! This is definitely something I want to support, but an initial pass seems to indicate it may not be super straightforward because of the way React handles non-hook methods provided by multiple mixins (that is: it doesn't). I'll give this a closer look soon.

BinaryMuse avatar Feb 15 '15 18:02 BinaryMuse

you could hook one of the lifecycles that get merged and dynamically create handlers that could then be enumerated?

nelix avatar Feb 18 '15 10:02 nelix

Isn't the only non-hook method in StoreWatchMixin the private _setStateFromFlux?

dantman avatar Aug 06 '15 12:08 dantman