ngrx初识
在使用之前需要安装ngrx
npm install @ngrx/store --save
或者
yarn add @ngrx/store
ngrx/store:保存了ReduxAPI的核心概念,使用RxJS扩展的Redux实现。使用可观察对象来简化了监听事件的订阅等操作。
dispatch&reducer&state
dispatcher,reducer,state都是基于BehaviorSubject的,BehaviorSubject:储存着要发射给消费者的最新的值。无论何时一个新的观察者订阅它,都会立即接受到这个来自BehaviorSubject的”当前值”。
Store
官方英文解释:
Like a traditional database represents the point of record for an application, your store can be thought of as a client side ‘single source of truth’, or database. By adhering to the 1 store contract when designing your application, a snapshot of store at any point will supply a complete representation of relevant application state. This becomes ex