3 ms·
The choice of `set` taking a function is a questionable one. I know this is fairly common for JS libraries but IMHO it should only be used when you know that th
by kevincox 6y ago
The choice of `set` taking a function is a questionable one. I know this is fairly common for JS libraries but IMHO it should only be used when you know that the value can't naturally be a function. Otherwise it is a footgun.
let someval = () => 1234;
state.set(someval) // Oops.
You need to remember to write the following if the value might be a function.
state.set(() => someval);
I would have just made this a separate function and call it `.update()`.