collective-soundworks / soundworks

Creative coding framework for distributed applications based on Web technologies.
http://soundworks.dev
BSD 3-Clause "New" or "Revised" License
114 stars 7 forks source link

SharedState observe() method and SharedStateCollection for same node #69

Closed jipodine closed 11 months ago

jipodine commented 11 months ago

The documentation of the observemethod states:

The states that are created by the same node are not propagated through the observe callback.

While I understand that their is a use for this, it seems a bit counter-intuitive as the default behaviour. In particular, when moving code from a client (controller, pure observer) to the server (where creation of states may happen), the result changes.

The wide implications of this to the SharedStateCollection seem even more bizarre to me. It is not documented, but as most of the methods rely on on underlying observe, no locally created state ever appear in them: find, forEach, onAttach, onUpdate, etc.

I do not know what would be a good solution

b-ma commented 11 months ago

Yup right, I would go for the excludeLocal parameter solution, i.e. something like:

StateManager::observe(schemaName, callback, { excludeLocal = false } = {});
StateManager::getCollection(schemaName, { excludeLocal = false } = {});
b-ma commented 11 months ago

Fixed with d0d255e and d0d255e