-
Notifications
You must be signed in to change notification settings - Fork 874
refactor(site): expose time values in render functions as centralized, pure state #17587
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
base: main
Are you sure you want to change the base?
Conversation
@Parkreiner does this have any relation to the Time Variance Authority (TVA) in the Marvel Universe? |
No, but that is where Class Variance Authority got its name from (which we use in the frontend to manage style variants) |
* updates are happening too frequently in React, restructure how you're | ||
* composing your components to minimize the costs of re-renders. | ||
*/ | ||
export class TimeSync implements TimeSyncApi { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might end up splitting this class up into a base TimeSync
class with a smaller, framework-agnostic API, and a ReactTimeSync
class that composes TimeSync
into it
WIP. Mainly getting this in place to get feedback on the interfaces, but I might not be able to start this officially until the next sprint.
Examples of using the hook
Getting a new date from the hook (the hook will trigger an update to TimeSync every second, unless there is another consumer that's mounted and has a faster update interval)
Getting a one-time date from the hook (the hook can still re-render if there are other consumers that trigger an update)
Getting a derived value from the hook (even if there is an update for the underlying TimeSync class, the hook will only re-render if the result of the
select
call is different compared to last time)With explicit type parameter