Does find method set up shallow tracking? #284
-
According to the document https://legendapp.com/open-source/state/usage/observable/#arrays, const state = observable({
messages: [{ value: "hello" }]
})
observe(() => {
const emptyMessage = room.messages.find((message) => message.value.peek() === "")
if (emptyMessage) {
console.log("Empty message found")
}
})
state.messages.push({ value: "" }) // "Empty message found" <- this is expected
state.messages[0].value.set("") // "Empty message found" <- this is not expected To achieve what I expected, I need to rewrite it as follows: observe(() => {
const emptyMessage = room.messages.get(true).find((message) => message.value === "")
if (emptyMessage) {
console.log("Empty message found")
}
})
state.messages.push({ value: "" }) // "Empty message found"
state.messages[0].value.set("") // (nothing logged) Is the document incorrect, or did I misunderstand the meaning of "shallow tracking"? |
Beta Was this translation helpful? Give feedback.
Answered by
jmeistrich
May 21, 2024
Replies: 1 comment
-
Sorry for the delay! This should be fixed in the latest @next version and will be in the upcoming v3. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
nightire
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sorry for the delay! This should be fixed in the latest @next version and will be in the upcoming v3.