Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get the global state change in one of the other app? #46

Open
nithincs20 opened this issue Sep 6, 2022 · 0 comments
Open

How to get the global state change in one of the other app? #46

nithincs20 opened this issue Sep 6, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@nithincs20
Copy link

Describe the bug

(Not a Bug, it is a Question)
I have two apps built using redux and redux-micro-frontend, In this case how could I get the global state change happening in one place, to one of the other App?

Here is my code in the Main App component to subscribe the CounterApp

const globalStore = GlobalStore.Get(false);
const globalStateChanged = (stateChanged) => {
        const stateC = globalState.CounterApp;
        console.log({ stateChanged, stateC });
};
globalStore.SubscribeToGlobalState('CounterApp', globalStateChanged);

And in the other App(Counter app), a method is triggered by the button click. Below is the code for that. (we have the same reducer and actions file that is created from the samples projects under the library)

const incrementGlobal = () => {
    globalStore.DispatchAction("CounterApp", IncrementGlobalCounter());
};

But I don't see the globalStateChanged invocation and the console print in Main App method. What will be the issue here? Are we missing anything here, and if you could share the code for the right approach it would be great.

@nithincs20 nithincs20 added the bug Something isn't working label Sep 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant