signaldb
signaldb copied to clipboard
Using $set on an array to modified an object/item inline doesn't trigger the SyncManager
As title mentions, the following code will not trigger SyncManager properly.
It does seem to cause a pull to happen, but nothing ever gets pushed, am I doing something wrong here or perhaps this is a bug?
updateTimer(task: Task, timerIndex: number, timer: TaskTimer) {
this.updateOne(
{ id: task.id },
{
$set: {
[`timers.${timerIndex}`]: timer,
},
},
);
}
Your code looks okay. Could you provide a minimal reproduction repo?
I have similar problems, it seems like if I use either dot-notation or nested objects as $set value, the sync manager does not pick up the changes. I created a stackblitz to reproduce the issue, but there it works like a charm:
https://stackblitz.com/edit/signaldb-playground?file=main.js
stackblitz.com/edit/signaldb-playground?file=main.js
I updated the stackblitz, it now reproduces the issue. If the nested object already exists and you want to modify it via dot.notation it won't trigger a sync since computeChanges does not find the change.
Thanks @maxfriedmann for your analysis and reproduction. I've included new tests and fixed this issue in #1689 🙂
Fix released in @signaldb/[email protected] 🎉