Changes in Observable not reflected in View

后端 未结 3 688
没有蜡笔的小新
没有蜡笔的小新 2021-01-19 19:30

I basically followed this guide to implement an Observable data service.

In a store class (ItemsStore), I have my BehaviorSubject which hol

3条回答
  •  别那么骄傲
    2021-01-19 20:10

    The items property should be Observable, but you set it as BehaviourSubject type. In your link there is:

    @Injectable()
    export class TodoStore {
        private _todos: BehaviorSubject> = new BehaviorSubject(List([]));
    
        public todos: Observable> = this._todos.asObservable();
    
        constructor(private todoBackendService: TodoBackendService) {
            this.loadInitialData();
        }
        ...
    }
    

    so assuming you followed this tutorial you should do something like this:

    private _items: BehaviorSubject> = new BehaviorSubject(List([]));
    public items: Observable> = this._items.asObservable();
    

提交回复
热议问题