MapSchema clear()

27 Oct 2021, 22:32

Hi there,

We're running into some issues with a MapSchema that we are trying to synchronize between the server and client. We want to clear the map via map.clear() and have the changes propagated to the client. What should we be implementing on the client side, onRemove that removes each element in the map by id or onChange on the parent property as a bulk change?

27 Oct 2021, 22:49

It looks like running map.forEach( (elt) => map.delete(elt.id) ) on the server side triggers the onRemove on the client side properly, is this the recommended way to clear a MapSchema?

28 Oct 2021, 03:38

It seems there's no clear function in a map.
How about renew your MapSchema?

13 Dec 2022, 00:49

@coco hi, sorry for the necro, but I'm curious if this method will leave memory leaks or will colyseus handle the cleanup on its own. Thanks!