How to read a signal's data built via a store?
paulrouget opened this issue · comments
let todos = store({ x: 42 }, /* some setters */)
I guess I have to do: todos.value.x
? I was expecting todos.x
to work, or at least to have value
documented somewhere? Or should I also add getters along the setters? Or am I missing something?
Also, the codepen is outdated and use the old version API.
Afaict todos.x
does work? Both with store()
from v12.x and signal()
from v13.0.0.
Also, the codepen is outdated and use the old version API.
Looks like it's using signal()
to me, unless it was just changed. ;-)
Afaict
todos.x
does work? Both withstore()
from v12.x andsignal()
from v13.0.0.
Ah, I must do something wrong:
let {store} = reef;
let todos = store({ x: 42 }, {})
console.log(todos.value.x); // 42
console.log(todos.x); // undefined
Also, the codepen is outdated and use the old version API.
Looks like it's using
signal()
to me, unless it was just changed. ;-)
From https://reefjs.com/advanced/#stores:
Isn't that outdated: Try store action functions on CodePen → ?
Ah, I must do something wrong:
Maybe you're using a really ancient version? Double check if your wires are plugged in. ;-)
Or alternatively, maybe that's not actually the full testcase?
Isn't that outdated
Yes, I was talking about https://codepen.io/cferdinandi/pen/wvmoPMg
Good catch! This is an oversight in the docs.
For data store()
objects, the data you get back is immutable and has to be accessed on the value
property. This ensures that the action methods don't collide with the data and provides a way to ensure the data can't be overwritten directly.
I'll update the docs to properly document this.
Fixed the docs!