You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hikari's rest interface and its cache present two alternate ways to perform many tasks, either through an object from the cache or directly on the rest API. While this makes sense from Hikari's perspective as a foundation for other libraries, it can pose a challenge to developers who must decide on the correct interface for each task. Worse as well, the consequences for choosing the wrong interface may not be immediately obvious. To break out The Zen of Python,
There should be one-- and preferably only one --obvious way to do it.
A solution I've seen for this implemented in other API libraries is lazy loading objects. For example, a TextChannel could be instantiated from purely its Snowflake ID, which would be enough to perform many operations through the rest interface. Attempts to access a property could then pull in information from the cache.
This is something that should be considered carefully though because its implementation greatly increases scope and documentation requirements. There's also the problem of async and lazy loading properties, a developer isn't going to await a property access. Would be cool to get other opinions on this but I think I'm still the only person using this library 🥲
As an example for a pattern for loading properties asynchronously, asyncpraw simply returns None unless you have called refresh().
The text was updated successfully, but these errors were encountered:
Hikari's
rest
interface and its cache present two alternate ways to perform many tasks, either through an object from the cache or directly on therest
API. While this makes sense from Hikari's perspective as a foundation for other libraries, it can pose a challenge to developers who must decide on the correct interface for each task. Worse as well, the consequences for choosing the wrong interface may not be immediately obvious. To break out The Zen of Python,A solution I've seen for this implemented in other API libraries is lazy loading objects. For example, a TextChannel could be instantiated from purely its Snowflake ID, which would be enough to perform many operations through the
rest
interface. Attempts to access a property could then pull in information from the cache.This is something that should be considered carefully though because its implementation greatly increases scope and documentation requirements. There's also the problem of async and lazy loading properties, a developer isn't going to
await
a property access. Would be cool to get other opinions on this but I think I'm still the only person using this library 🥲As an example for a pattern for loading properties asynchronously, asyncpraw simply returns None unless you have called
refresh()
.The text was updated successfully, but these errors were encountered: