microsoft / redux-micro-frontend

This is a library for using Redux to manage state for self-contained apps in a Micro-Frontend architecture. Each self-contained isolated app can have its own isolated and decoupled Redux store. The componentized stores interact with a global store for enabling cross-application communication.
MIT License
344 stars 64 forks source link

InvokeGlobalListeners is not called when RegisterStore is used #16

Closed rotty3000 closed 3 years ago

rotty3000 commented 3 years ago

Describe the bug InvokeGlobalListeners is not called when RegisterStore is used

To Reproduce Steps to reproduce the behavior:

  1. Register a manually created store using GlobalStore.RegisterStore
  2. subscribe to global state using globalStore.SubscribeToGlobalState(..)
  3. trigger any store actions
  4. global listeners are not triggered

Expected behavior global listeners are called for state changes in any store.

patrickCode commented 3 years ago

I will investigate a bit more on this and get back on this issue. For clarification when you say you are triggering any store actions, are you triggering the action on the store directly or via the GlobalStore methods?

rotty3000 commented 3 years ago

so for stores which are RegisterStore'd rather than CreateStore'd.

You can see that in CreateStore you've called appStore.subscribe(this.InvokeGlobalListeners.bind(this));

but in RegisterStore you haven't.

In fact it looks almost like if you move line 71 to bellow line 98 you'd cover both scenarios.

patrickCode commented 3 years ago

Actually I was thinking of the same thing. I will fix and release a new version on Monday. Does that work for you?

patrickCode commented 3 years ago

Sorry I got busy with some critical work. Thanks for the PR @rotty3000

rotty3000 commented 3 years ago

No problem at all! Thanks for merging 😊

On Sun., Mar. 28, 2021, 9:50 a.m. Pratik Bhattacharya, < @.***> wrote:

Sorry I got busy with some critical work. Thanks for the PR @rotty3000 https://github.com/rotty3000

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/microsoft/redux-micro-frontend/issues/16#issuecomment-808899774, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABD2TA3ZGJSPXGC4MENNNDTF4XZHANCNFSM4ZCVPGYQ .

patrickCode commented 3 years ago

Version 1.1.0 was release which will have the changes