title: Angular ngrx-store: How to share store among modules (main module / feature module)
body: <p>I have two angular modules: <em>main</em> and <em>feature</em>:</p>
  
  <p>Main / root module:</p>
  
  <pre><code>@NgModule({
      imports: [
          StoreModule.forRoot({router: routerReducer}),
          EffectsModule.forRoot([...]),
          ...
      ],
      declarations: [],
      ...
  })
  export class AppModule {}
  </code></pre>
  
  <p>Feature module:</p>
  
  <pre><code>@NgModule({
      imports: [
          StoreModule.forFeature('feature', {someValue: someValueReducer}),
          EffectsModule.forFeature([...]),
          ...
      ],
      declarations: [],
      ...
  })
  export class FeatureModule {}
  </code></pre>
  
  <p><strong>I need to access 'feature' slice of data in main module to conditionally display / activate application tab based on data stored in <code>feature</code> module.</strong></p>
  
  <p>(In other words I need a global / shared piece of state accessible by all modules <em>main</em> and any <em>feature</em> module.)</p>
  
  <ol>
  <li>Is it possible to do that?</li>
  <li>Is it considered as good practise?</li>
  </ol>
  
  <p>Currently I can't do that since there is no <code>feature</code> state in main <code>AppState</code>:</p>
  
  <pre><code>export interface AppState {
      router: RouterReducerState&lt;RouterStateUrl&gt;;
  }
  </code></pre>
  
  <p>And typescript indicates error <code>this.store.select('feature')</code> since there is no <code>feature</code> key of main store <code>AppState</code>.</p>
  
  <p>Using <code>selector</code>: <code>this.store.select(selectFeatureValue)</code> I am getting runtime error:</p>
  
  <pre><code>export const selectFeatureModule = createFeatureSelector&lt;FeatureState&gt;('feature');
  export const selectFeatureValue = createSelector(selectFeatureModule ,
  (state: FeatureState) =&gt; state.someValue);
  </code></pre>
  
  <p>I am getting error in main AppComponent:</p>
  
  <blockquote>
    <p>TypeError: Cannot read property 'someValue' of undefined</p>
  </blockquote>