RicardoJBarrios/elf-sync-state

Sync is done intermittently when updating entities previously recovered by using the query command

Closed this issue · 1 comments

While I was learning elf and this great third-party add-on, I found a strange behavior I would like to report to let you check whether it is a bug or not.

It came out that, when updating the elf entity (previously recovered by using the "query" command) the synchronization is done in an intermittent manner.

This behavior is harder to explain than to demonstrate, so I updated the "Angular Sync State Example" in stackblitz to do so:

https://stackblitz.com/edit/angular-elf-sync-state-bvdfyu

To reproduce the problem, open the result in two different tabs, add some items and then note that when pressing the "update" button the entities are not always synchronized.

As a workaround, I found it necessary to clone the entity before applying the "update" command in elf, as you can see in this example:

https://stackblitz.com/edit/angular-elf-sync-state-eizsup

Note the "todo = { ...todo };" line in the update() method.

Finally, this sounds very strange to me... and I would like someone to confirm whether there is something I am doing wrong at my side or there is a bug somewhere in elf/this add-on.

I guess the "strange" behavior is caused by the fact of changing an immutable result returned by the query() command and there is not a bug on this project.
Maybe someone can confirm this.