reflux / refluxjs

A simple library for uni-directional dataflow application architecture with React extensions inspired by Flux
BSD 3-Clause "New" or "Revised" License
5.36k stars 330 forks source link

How are keys handled if a component is attached to multiple stores with the same key? #535

Closed rkpatel33 closed 6 years ago

rkpatel33 commented 6 years ago

What will happen if you attache Store1 and Store2 to a component using:

this.stores = [Store1, Store2];

and both have and .isLoading flag? If they get overwritten, is there anyway to preserve the two flags, or do you just have to have them differenly, like .isStore1Loading and .isStore2Loading?

BryanGrezeszak commented 6 years ago

Quite simply: it's not handled. So don't do that.

My basic goal was to keep the automatic mapping extremely simple and predictable. So if you use conflicting names they will do the most predictable thing possible: conflict 😄

You can either give them unique names, or you can use the more imperative mapStoreToState method of mapping state from store to components instead of attaching the store via this.stores.

See this.mapStoreToState docs.

rkpatel33 commented 6 years ago

Ok, that is the assumption I have been working on but thanks for confirming.


Rishi Patel | mail@rishinyc.com

On Sat, Apr 21, 2018 at 11:26 AM, Bryan Grezeszak notifications@github.com wrote:

Quite simply: it's not handled. So don't do that.

My basic goal was to keep the automatic mapping extremely simple and predictable. So if you use conflicting names they will do the most predictable thing possible: conflict 😄

You can either give them unique names, or you can use the more imperative mapStoreToState method of mapping state from store to components instead of attaching the store via this.stores.

See this.mapStoreToState https://github.com/reflux/refluxjs/tree/master/docs/components#manually-mapping-states-with-thismapstoretostate docs.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/reflux/refluxjs/issues/535#issuecomment-383318491, or mute the thread https://github.com/notifications/unsubscribe-auth/ADn5wQokvPgM3EX_FcgmLunAJJmlhfShks5tq3nvgaJpZM4QG09J .