How to get current value of State object with @ngrx/store?

后端 未结 10 1504
失恋的感觉
失恋的感觉 2020-12-08 06:13

My service class, before calling a web service, needs to get a property called dataForUpdate from my state. Currently, I\'m doing it like this:



        
10条回答
  •  爱一瞬间的悲伤
    2020-12-08 06:52

    Update for @ngrx/store v4.x

    As of v4.x we are forced to put the take operator into the pipe like that to get it synchronous:

    function getState(store: Store): State {
        let state: State;
    
        store.pipe(take(1)).subscribe(s => state = s);
    
        return state;
    }
    
    

提交回复
热议问题