-
Notifications
You must be signed in to change notification settings - Fork 1
Description
In this issue I'll list some known limitations for both the ShareableMap and ShareableArray that are in most cases a result of limitations posed by the JavaScript programming language (i.e. which are impossible to overcome).
Object references
Objects added to the Map or Array are serialized and deserialized when necessary. This means that if you'll try to retrieve an object that was added to either of these data structures before, a new "identical" object will be returned, but the object references will be different. Contents of the objects are the same, object references are not.
So, be careful when you're relying on this system to, for example, update an object that's retrieved dynamically.
const map = new ShareableMap();
map.set("myKey", []);
// This value will not actually be pushed to the array that was set to `"myKey"` before
// because the array object returned by the Map is not the exact same.
map.get("myKey").push(1);
// Do this instead (and overwrite the array that was set in the Map completely).
const previousArray = map.get("myKey");
previousArray.push(1);
// Overwrite the array in the map completely.
map.set("myKey", previousArray);ShareableMap is not ordered
In comparison to the Map implementation provided by JavaScript itself, the ShareableMap does not keep track of the ordering of it's items. The ordering is never guaranteed and the order in which items will be returned when iterating over the map is not guaranteed to be deterministic.