-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Description
I wrote a whole thing and it got deleted because I forgot to submit the issue and I can't bother redoing it but I would hope for something like
let x = state(initial-value) // No way to access this state besides through `x`
let y = state(initial-value, key: "some-y-state-key") // Any state constructed with the same key will be associated with `y`.
This will break existing code, but using a named argument for the key makes existing code a hard error always, rather than things just not working sometimes (specifically with string-valued states)
There shouldn't be a way to construct a state with no arguments. If no initial value is provided, the state ought to be referencing some existing state in the document.
If you can think of a backwards compatible way to make the key optional I'd be open to hear it
Use Case
To avoid name collisions, and because usually there's no use for multiple states with the same key, so it just imposes a quirky and potentially brittle api