ngrx Load data from server only if the store is empty

前端 未结 4 1321
离开以前
离开以前 2021-01-01 15:19

I have a static set of data, a list of countries, that are used on some components. This data is loaded upon the ngOnInit() of these components but I\'d like to

4条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-01 15:56

    My answer is a variation from Hetty de Vries answer's. If you simply want to retrieve the contents of the store without touching the effects you could do something similar to this:

    this.store.select(state => state.producer.id).forEach( id => {
    ...
    }
    

    supposing that your store contains a producer object with an attribute id.

提交回复
热议问题