Setup a store
To create a store, you need to import and use the NgStore
class. NgStore
accepts a single parameter as the initial state of your store.
counter-store.ts
That's the simplest way you create a store. If you want to fully type-safe your store, you can populate the NgStore
generic parameters. The first generic parameter refers to the type of state. Then the second one refers to the available actions you can use in your store.
counter-store.ts
Finally, to make the store injectable in your AngularJS application, you need to attach it to AngularJS service.
It is recommended to always export the types of store's state, store's actions, and the store itself so you can easily reuse it inside your application.
counter-store.ts
Last updated