I wonder what’s the intended future for two conven...
# compose
e
I wonder what’s the intended future for two conventions of using
state
(apart from
+
operator):
Copy code
var foo by +state { 0 } // property delegation to state
var (foo, setFoo) = +state { 0 } // destructuring state
Is the second-one just a React/JS gimmick because “we can” or is it really useful in some use-cases?
5
r
I could see use for
setFoo
in cases where you might want to use techniques like currying or function composition. How do you define
setFoo
with the
+state
api?
j
The two variants are roughly equivalent; I don't think there is a compelling reason to prefer one over the other. The property delegation might be slightly preferable because we would more naturally warn if you attempt to mutate that
var
by capturing inside a child composable.