ではない私は、私は以下のBehaviourSubject を理解しようとしていますRxjs に新しいです私のコードは、私は私のプロジェクトを実行すると、私はBehaviourSubjectのdistinctUntilChanged()関数
私のコンソールにこのエラーが出ますexport interface State {
items: Items[]
}
const defaultState = {
items: []
};
const _store = new BehaviorSubject<State>(defaultState);
@Injectable()
export class Store {
private _store = _store;
changes = this._store.distinctUntilChanged()
.do(() => console.log('changes'));
setState(state: State) {
this._store.next(state);
}
getState() : State {
return this._store.value;
}
purge() {
this._store.next(defaultState);
}
}
です
platform-browser.umd.js:1900 EXCEPTION: Error: Uncaught (in promise):
EXCEPTION: Error during instantiation of Store! (StoreHelper -> Store).
ORIGINAL EXCEPTION: TypeError: this._store.distinctUntilChanged is not a function
誰でも私を助けることができます。また、私がしようとしているのは、私のモデルオブジェクト用のStoreを作成することです。他の簡単な方法があれば、それを提案することができます。
何か助けていただければ幸いです。
こんにちは、私はWebstormを持っていて、私がLettable Operatorsを使用しているとき、Webstormはそれらを「未使用」のインポートとして保持しています。 –