Platform: Real scenario, practical sample app with lazy loading in mind

Created on 26 Jun 2017  路  4Comments  路  Source: ngrx/platform

Feature Request / Document Request

@ngrx/platform may benefit from a more complete and practical sample app.

This package ngrx-lazy-load by @FabienDehopre is really easy to follow and covers many things.

Lazily loaded modules are only referenced once (indirect), and that is in the root route via the loadChildren methods. As per the following example.

const routes: Routes = [
  {
    path: '',
    redirectTo: 'home',
    pathMatch: 'full'
  },
  {
    path: 'home',
    component: HomeComponent
  },
  {
    path: 'one',
    loadChildren: './one/one.module#OneModule'
  },
  {
    path: 'two',
    loadChildren: './two/two.module#TwoModule'
  }
];

Effects (hacked), Models, Services, Actions, Reducers & States (no Persistence example), are all within the lazily loaded modules themselves without any external direct referencing.

Most helpful comment

I've been creating a store directory inside my featureModule with the following files: reducer, actions, state (with initial state), effects and a service that exposes the store (and retrieving the state with rxjs itself, not with reselect).
I tried this format with ngrx/platform and it is working ok. Lately, I also tried to package all these files as a sub-module of my feature module as well.
I've been working on a VsCode plugin to generate the files using this structure of files, and as soon as I have some spare time I'm planning on publishing it and also counting on getting your feedback as well :)

All 4 comments

Yes please! Having quite a bit of trouble figuring this out

I've been creating a store directory inside my featureModule with the following files: reducer, actions, state (with initial state), effects and a service that exposes the store (and retrieving the state with rxjs itself, not with reselect).
I tried this format with ngrx/platform and it is working ok. Lately, I also tried to package all these files as a sub-module of my feature module as well.
I've been working on a VsCode plugin to generate the files using this structure of files, and as soon as I have some spare time I'm planning on publishing it and also counting on getting your feedback as well :)

@loaine: Thanks! VSCode plugin sounds awesome, too :) Maybe it coud be extended to cover even more repetitive work such as creating actions (and corresponding reducers).

(Here is a link to an example by @loiane: https://github.com/loiane/angular-redux-ngrx-examples/tree/master/angular-ngrx-lms-firebase for anyone reading this issue)

The example app has been merged by #12 which contains an example of lazy loading state

Was this page helpful?
0 / 5 - 0 ratings