Git Product home page Git Product logo

Comments (5)

RobCannon avatar RobCannon commented on May 30, 2024 2

Yes, please. I am running into trouble with setting up the modules for the AppModule and each of my Store module. It would be good to see all of the @NgModule bits need to wire everything up.

from ngrx-actions.

longilineo avatar longilineo commented on May 30, 2024 1

same for me. Here I tried to exercise with a simple Effect: https://stackblitz.com/edit/angular-qddzem?file=app%2Ftodos%2Ftodos.module.ts
On console I get NullInjectorError: No provider for ReducerManager!

from ngrx-actions.

RobCannon avatar RobCannon commented on May 30, 2024

Here is what I had to use to get this working. I am hoping that there is a way to reduce some of this. The reducers and metareducers seem like they are duplicating some of what NgrxActionsModule.forRoot should do, but I found it was needed to get things to work. Perhaps there is a better way.

BUT, I do love that I can combine my @actions and @effects into one class. It helps to not have to jump to several files just to handle one user action. I would like to see a way to create one file that would combine the actions, effects and actions classes for one user action into one place.

This is from my app.module.ts:

export interface AppState {
  order: OrderStore;
}

export const reducers: ActionReducerMap<AppState> = { order: null };

export const metaReducers: MetaReducer<AppState>[] = !environment.production ? [storeFreeze] : [];

@NgModule({
  declarations: [AppComponent, TopMenuComponent],
  imports: [
    CommonModule,
    BrowserModule,
    BrowserAnimationsModule,
    HttpModule,
    HttpClientModule,
    AppRoutingModule,
    OrderModule,
    StoreModule.forRoot(reducers, { metaReducers }),
    NgrxActionsModule.forRoot({
      order: OrderStore
    }),
    !environment.production ? StoreDevtoolsModule.instrument() : []
  ],
  bootstrap: [AppComponent]
})

And here is an excerpt from my order.module.ts:

@NgModule({
  imports: [
    CommonModule,
    FormsModule,
    ReactiveFormsModule,
    RouterModule.forChild(routes),
    NgrxActionsModule.forFeature({ order: OrderStore })
  ],
  declarations: [
    OrderPageComponent,
    OrderListComponent
  ],
  providers: [OrderStore, OrderService],
  exports: [RouterModule]
})

I hope that helps.

from ngrx-actions.

lanovoy avatar lanovoy commented on May 30, 2024

@RobCannon you actually do not need to pass any reducers into forRoot of the StoreModule import. This works just fine: StoreModule.forRoot([])

from ngrx-actions.

RobCannon avatar RobCannon commented on May 30, 2024

@lanovoy Thanks! One slight change to support store freeze:

    StoreModule.forRoot({}, { metaReducers: !environment.production ? [storeFreeze] : [] }),
    NgrxActionsModule.forRoot({
      order: OrderStore
    }),
    !environment.production ? StoreDevtoolsModule.instrument() : []

from ngrx-actions.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.