Issues related to Map
ngwaitat opened this issue · 4 comments
-
Call remove() to clear a property will not fire property change, must set a different property in order to force fire.
-
Create a Map M1, put it as property of another Map M2. Call remove on M1 to remove the property pointing to M2, and put M2 as the property of another Map. Reload the page and open the collaborative object again, will find all M2's lost all properties and seemed to be destroyed. Not sure whether this is by design or an issue, currently I work around by not call remove but overwrite with a different value.
Call remove() to clear a property will not fire property change, must set a different property in order to force fire.
Sorry, but I couldn't reproduce it, using both delete() and remove() methods.
Was the listener defined in the container node (or any ancestor) of the property?
I will be happy to review your code if you want.
Create a Map M1, put it as property of another Map M2. Call remove on M1 to remove the property pointing to M2, and put M2 as the property of another Map. Reload the page and open the collaborative object again, will find all M2's lost all properties and seemed to be destroyed. Not sure whether this is by design or an issue, currently I work around by not call remove but overwrite with a different value.
Yes, this behavior is by design. Setting a new property to an existing node (map or list) just makes a reference to it, like symbolic links in Linux. When a node is delete/remove from the object its content is also deleted, even existing a reference to it in another property.
Current rationale is
a) approach "linking" properties. On property deletion, only remove node's content if there is no more references. However, since reference count is costly I decided not to implement it.
A possible alternative is:
b) To copy property values when a existing property is assigned to other property in the object. This could imply to perform a deep copy of nodes, which it is also costly.
Thanks Pablo, first I'd like to confess that I was actually using the older version, the same version used in JetPad. The reason is that when using the latest version I found the listener didn't work. And I actually thought the one used by JetPad is newer, because the listener did work for me, but now I know I'm wrong.
I test again the remove() in latest version, and it works just fine. And I used the latest SwellRT version and changed my code to suit the latest API and everything work very nicely. Thank you very much, and please keep up the good work 👍