redux-dynamic-modules icon indicating copy to clipboard operation
redux-dynamic-modules copied to clipboard

How to wait completion of initialactions when I use a module dependencies?

Open sinack-old opened this issue 6 years ago • 0 comments

I have 2 modules. There are authModule and userPageModule.

authModule is get user login status by initialactions. userPageModule is used to display the user page using the fetched login status by authModule.

Therefore, I want these modules to be loaded in the correct order. But looks like userPageModule will be loaded without waiting for initialaction of authModule to complete to me.

Is the order of this process correct? If so, how can I do what I want?

export const authModule = () => {
  return {
    id: 'auth',
    reducerMap: {
      auth: authReducer,
    },
    sagas: [watchAuthUser],
    initialActions: [getLoginStatus.start()],
  };
};
export const userPageModule = () => {
  return {
    id: 'userPage',
    reducerMap: {
      profile: profileReducer,
    },
    sagas: [watchPage],
  };
};
export const UserPage = () => (
  <DynamicModuleLoader modules={[authModule(), userPageModule() ]}>
    <Page />
  </DynamicModuleLoader>
);

const Page = () => (
  <>
    // some components that use user data
  </>
)

sinack-old avatar Dec 23 '19 10:12 sinack-old