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

Partial objects and lazy loading #21

Closed kawaii closed 4 years ago

kawaii commented 5 years ago

Objects need to know when they have not been fully populated. This can happen when the API sends us a subset of a hash instead of a full object hash.

This knowledge would also help us determine whether an object is new and thus needs to be created on Discord's end.

We could probably use the same or similar mechanism to know whether we need to update any fields, and which ones, thus enabling us to send PUT (or PATCH if that's an option) instead of a POST, which would help with #16.

We can also use this for lazy loading since we can populate an object with just its ID (for example) and let it fetch the rest of the data as needed.

Altreus commented 4 years ago

We've implemented this using Object::Delayed