Link to home
Create AccountLog in
Avatar of Dorababu M
Dorababu MFlag for India

asked on

ngrx how to get the stroed value from selector instead of observable

Hello I have the following code where I am trying to store a value to store and get it I have created a sample code for the same

https://stackblitz.com/edit/stackblitz-starters-rfqf6h?file=src%2Fapp%2Fapp.component.ts

I have created the following store

action.ts
import { createAction, props } from '@ngrx/store';
export const setTrackLength = createAction(
'[Track] Set Value',
props<{ lengthOfTrack: number }>()
);

Open in new window

selector.ts

import { createFeatureSelector, createSelector } from '@ngrx/store';
import { TrackState } from './track.state';

export const setTrackLength = createFeatureSelector<TrackState>('trackState');

export const getTrackLength = createSelector(
  setTrackLength,
  (state) => state.trackLength
);

Open in new window

 am storing and getting the value but it display as follows where I need the value to be 1


User generated imageUser generated image

In the console I can see the value as per the second image I need that value to be read instead of entire observale


ASKER CERTIFIED SOLUTION
Avatar of Dorababu M
Dorababu M
Flag of India image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer