Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Objects should update with update events #16

Open
Altreus opened this issue Feb 20, 2019 · 0 comments
Open

Objects should update with update events #16

Altreus opened this issue Feb 20, 2019 · 0 comments
Labels
enhancement New feature or request
Milestone

Comments

@Altreus
Copy link
Member

Altreus commented Feb 20, 2019

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.

@kawaii kawaii added this to the 1.0 milestone Feb 27, 2019
@kawaii kawaii added the enhancement New feature or request label Feb 27, 2019
@kawaii kawaii modified the milestone: 1.0 Mar 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants