Closed
Description
@Rich-Harris
Right now, if we need to make some multiple manipulations with the state we need doing something like:
const { foo, bar } = this.get();
++foo;
bar = 'baz';
this.set({ foo, bar });
I think it'll be nice if we'll able to create some function which will receive the current state as an argument and return a new state, and use this function as an argument in methods set():
export function changeFooBar({ foo, bar }) => {
++foo;
bar = 'baz';
return { foo, bar };
}
...
import { changeFooBar } from '...';
...
this.set(changeFooBar);
I think I can provide a PR for that change. Seems it's just a few lines of code.
Metadata
Metadata
Assignees
Labels
No labels