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

AppB is able to modify store in AppA that doesn't have registered global actions #25

Open harishajdarevic opened 3 years ago

harishajdarevic commented 3 years ago

Describe the bug Hi everyone,

I'm playing arround with this library and I found out that I'm able to update state from AppA -> AppB even if AppB doesn't have registered global actions.

AppA:

            this.globalStore = GlobalStore.Get(false);
            this.globalStore.CreateStore('MFAppStore', MfReducer, []);
            this.globalStore.RegisterGlobalActions('MFAppStore', null);

AppB:

                this.globalStore = GlobalStore.Get(false);
                this.globalStore.CreateStore('GlobalAppStore', GlobalReducer, []);
                this.globalStore.RegisterGlobalActions('GlobalAppStore', [INCREMENT_GLOBAL, DECREMENT_GLOBAL]);

I'm able to dispatch action from AppB to AppA and modify the 'MFAppStore' even if there are not registered global actions.

In documentation ( readme ) it says:

this.globalStore.DispatchAction("App1", action); // This will dispatch the action to current app's store as well other stores who might have registered 'Action-1' as a global action

but it seems that it doesn't work as it is intended or I'm missing something?

Or it was always allowed?

Thanks

patrickCode commented 3 years ago

Ideally this shouldn't happen. Can you please give me an example of which action is modifying MFAppStore, and how are you dispatching it.