-
-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Is your feature request related to a problem? Please describe.
Since retrieving distinct changes for a particular state property is a very common scenario, I'd suggest introducing a method that would do that for you.
Similar, it'd be great if there was a method for updating a particular property of the state:
Describe the solution you'd like
pseudo code:
observe value changes to a particular state prop:
selectKey<K extends keyof StateType>(key: K): Observable<StateType[K]> {
return this.valueStream.pipe(
pluck(key),
distinctUntilChanged()
);
}update a particular state prop:
private updateKey<K extends keyof StateType>(
key: K,
updaterOrNewVal: StateType[K] | ((currentValue: StateType[K]) => StateType[K])
) {
this.bucket.set(state => {
const prev = state[key];
const updated = typeof updaterOrNewVal === 'function'
? updaterOrNewVal(prev)
: updaterOrNewVal;
return { ...state, [key]: updated };
});
}Describe alternatives you've considered
Additional context
Metadata
Metadata
Assignees
Labels
No labels