title: Angular7 - How i can load state from localStorage with nrgx-store/effects
body: <p>How i can load state from localStorage with nrgx-effects?</p>
  
  <p>When I initialize the application, I call</p>
  
  <pre><code>this.store.dispatch(new cartActions.LoadCart());
  </code></pre>
  
  <p>Next, the action CART_LOAD is triggered</p>
  
  <p><strong>cart.action</strong></p>
  
  <pre><code>export class LoadCart implements Action {
      readonly type = LOAD_CART;
  }
  
  export class LoadCartSuccess implements Action {
      readonly type = LOAD_CART_SUCCESS;
  
      constructor(public payload: any) {}
  }
  </code></pre>
  
  <p>Next, I listen to the effect</p>
  
  <pre><code>@Effect()
      loadCart$ = this.actions$.pipe(ofType(cartActions.LOAD_CART),
          tap(action =&gt; {
              return this.CartService.getCart().subscribe(cart =&gt; new cartActions.LoadCartSuccess(cart));
          })
      );
  </code></pre>
  
  <p><strong>cart.service</strong></p>
  
  <pre><code>getCart() {
      return JSON.parse(localStorage.getItem('cart'));
  }
  </code></pre>
  
  <p><strong>Local storage</strong></p>
  
  <pre><code>{products: Array(3), cartTotal: 3, cartCost: 12000}
  </code></pre>
  
  <p>But matter to LOAD_CART_SUCCESS does not reach</p>
  
  <p><a href="https://i.stack.imgur.com/Q69U2.png" rel="nofollow noreferrer">NgRx Store DevTools</a></p>
  
  <p>What I forgot to do is to place localStorage in the store during application initialization?</p>
  
  <p>.</p>