Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using @ngrx/store and @ngrx/core with System.js module loader

Tags:

angular

ngrx

In order to use @ngrx/store [ 2.2.1 ] and @ngrx/core [ 1.2.0 ] for state management in my sample Angular 2 [2.4.0] application I followed below steps

  1. Installed @ngrx/store [ 2.2.1 ] and @ngrx/core
  2. Added below import to root module

    import { StoreModule } from '@ngrx/store'; 
    

3 Added below code in packages section of systemjs.config.js file

 '@ngrx/core': {
          main: 'bundles/core.umd.js',
          format: 'cjs'
      },
      '@ngrx/store': {
          main: 'bundles/store.umd.js',
          format: 'cjs'
      }     

I am getting below error in browser console , when I browse to the website

Failed to load resource: the server responded with a status of 404 (Not Found) "http://localhost:62818/@ngrx/store/bundles/store.umd.js"

Any idea what needs to be modified to fix this issue.

like image 824
refactor Avatar asked Feb 10 '17 15:02

refactor


People also ask

Can we have multiple stores in NgRx?

The objective of this article is to provide a technical implementation of the NGRX for an application with a complexity that could benefit from adding feature store(s) in addition to the root store.

What is NgRx store used for?

NgRx/store is a library for managing state in your Angular applications, it is a reactive state management library powered by RxJS. Similar to Redux, this library can be used to manage the flow of data throughout your application, when actions are dispatched, reducers act on them and mutate the store.

What is NgRx store module?

The ngrx/store module allows you to define a slice of the root application state per each Feature module. The result is a single Root application state object, containing all the slice of states collected from all loaded Feature modules in the application.


1 Answers

As @ estus mentioned , this was a path issue . Adding below lines to map section with correct path resolved the issue

'@ngrx/core': 'node_modules/@ngrx/core/bundles/core.umd.js',
'@ngrx/store': 'node_modules/@ngrx/store/bundles/store.umd.js',
like image 85
refactor Avatar answered Nov 15 '22 03:11

refactor