shuppet / raku-api-discord

Raku module for interacting with the Discord API.
https://shuppet.com
BSD 3-Clause "New" or "Revised" License
30 stars 3 forks source link

Use lots of supplies #20

Open kawaii opened 5 years ago

kawaii commented 5 years ago

This might be a bad idea but we should experiment with it.

One model for the API to update itself would be to have all objects listen to the events supply on the API object and handle those events that are relevant to them. This is not terrible but it does mean discarding lots of things lots of times, since the majority of events will not be relevant to the listener.

The other model is to have the API re-despatch the event to those objects to which it is relevant, by means of a supply on each object that the object can listen to. Essentially, whenever we create an object by inflation, we create a supply on the object and attach it to the main event supply via some magic or other. waves hands

The difficulty might be in new objects that we POST in the first place. We would have to attach this supply after we learn that the new object was successfully created, so that the object updates itself in future.

It might also be difficult to handle a delete event properly so we may have to refactor a few things.

kawaii commented 5 years ago

Certain objects could also have their own supplies if we were going to throw supplies around a lot.

etc