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

StoreRouterConnectingModule throwing error on ng serve #183

Closed
lyndonoc opened this issue Jul 25, 2017 · 2 comments
Closed

StoreRouterConnectingModule throwing error on ng serve #183

lyndonoc opened this issue Jul 25, 2017 · 2 comments

Comments

@lyndonoc
Copy link

I am having a very strange issue with StoreRouterConnectingModule that is breaking my app.

To summarize the issue, whenever I import "StoreRouterConnectingModule" to start using @ngrx/router-store, it breaks my app giving me an error that says

"TypeError: Cannot assign to read only property 'microTask' of object '[object Object]'"

Here is what my code looks like.

export interface AppState {
    routes: fromRouter.RouterReducerState;
    layout: fromLayout.AppLayoutModel;
    player: fromPlayer.AppPlayerModel;
    search: fromSearch.YtSearchModel;
}

export const reducers: ActionReducerMap<AppState> = {
    routes: fromRouter.routerReducer,
    layout: fromLayout.layoutReducer,
    player: fromPlayer.playerReducer,
    search: fromSearch.ytSearchReducer
};

export const metaReducers: ActionReducer<any, any>[] = !environment.production
    ? [storeFreeze]
    : [];

these reducers are then imported in a module file like this.

const routes: Routes = [
    {
        path: '',
        children: [
            {
                path: 'explore',
                loadChildren: '../../explore/explore.module#ExploreModule'
            }
        ]
    },
    {
        path: '**',
        redirectTo: '',
        pathMatch: 'full'
    }
];

@NgModule({
    imports: [
        RouterModule.forRoot(routes)
    ],
    exports: [
        RouterModule
    ]
})
export class CoreRoutes {}

I put the routes in a separate module named "CoreRoutes", which is imported in the coremodule below.

@NgModule({
    declarations: [
        CoreContainerComponent,
        ...CoreComponents
    ],
    imports: [
        CommonModule,
        FormsModule,
        StoreModule.forRoot(reducers, {
            metaReducers
        }),
        CoreRoutes,
        StoreRouterConnectingModule,
        EffectsModule.forRoot([
            SearchEffects
        ]),
        !environment.production ? StoreDevtoolsModule.instrument() : [],
        ClarityModule.forChild(),
        SharedModule
    ],
    exports: [
        CoreContainerComponent
    ],
    providers: [
        YtPlayerService,
        YtDataService
    ]
})
export class CoreModule {}

This 'core-module' is then imported into app.module.ts

As soon as I remove StoreRouterConnectingModule, everything works except for router-store, of course.

I am completely lost as to what it is that is causing the error.

@lyndonoc
Copy link
Author

lyndonoc commented Jul 25, 2017

Somehow, removing the storeFreeze meta-reducer from CoreModule's imports made everything work. I'm still unclear what it is about the meta-reducer or StoreRouterConnectingModule that's causing this issue.

@brandonroberts
Copy link
Member

@ngrx/router-store isn't compatible with the store-freeze meta-reducer at the moment. See #97

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants