Open
Description
For example, a Channel object should update itself when we receive relevant messages from the Discord websocket.
Problem here is that if the user has intentionally changed a field, we will probably overwrite it with the data from Discord, even if that didn't change in the payload.
So the questions are:
- How do we get the update message into the various objects, given that the objects could have been generated directly via the API from an ID?
- How do we wire up the update stream to objects that get created by us?
- How do we know when a field is dirty?
I think the answers are something like:
- The base Object role should have a Supply on it. The API object will connect this supply to its own message handler, and emit relevant messages on the relevant objects' supplies when they arrive.
method handle-event($json) {
# some sort of despatch to the right type or whatever
# look it up by ID or something
$discovered-object.update-supply.emit($json);
}
-
Created objects will have to be recreated by anyone stubbornly holding onto them. We won't have an ID for it, so we might as well just re-fetch it and wire it up as normal.
-
I think there's a trait members can have so we know if they're dirty. Really it's just a hash on the meta-object full of booleans. We can make use of this to avoid overwriting properties that have
is-dirty
set to true.