I want to fetch the current state of a ngrx store without using subscribe. I tried some of the solutions I found but they usually gave me an undefined result, perhaps because my store is not set up correctly. I have managed to achieve this but I do not think that this is the best way of doing it. I am currently able to fetch the state like so:
I am defining a store instance in the component class:
ngStore: any;
In the constructor parameters I'm creating an instance of the specific store I want to use:
private calculatorSliderStore: Store<CalculatorSliderState>,
I am initializing the store instance in the constructor:
this.ngStore = this.calculatorSliderStore.pipe(select(getCalculatorSliderState));
I log the current state of the store:
console.log(this.ngStore.source.actionsObserver._value.payload);
This is all working but I do not think that this is the correct way of doing it. Can anyone confirm this and offer a better solution?