Currently, I am working on an Angular application that utilizes NGRX for state management. One of the challenges I am facing is dealing with a selector that returns an Observable.
export const mySelector = createSelector(state, (state: IState) => state.field.array);
The Observable returned by this selector has the format {name:string; age:number}[]
.
What I am trying to achieve is transforming this data format into something like {first-name:string}
. However, I am unsure about which operator I should use for this transformation.
My aim is to store the new data in a variable within the subscribe function, similar to the following:
myVariable: {first-name:string};
this.store.pipe(select(mySelector))
.pipe(//I need to find the right operator for data transformation here)
.subscribe(result => {myVariable = result})