Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@buenos-nachos
Copy link
Contributor

@buenos-nachos buenos-nachos commented Apr 28, 2025

WIP. Mainly getting this in place to get feedback on the interfaces now, 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)

const date = useTimeSync({
  idealRefreshIntervalMs: 1_000,
});

Getting a one-time date from the hook (the hook can still re-render if there are other consumers that trigger an update)

const date = useTimeSync({
  idealRefreshIntervalMs: Number.POSITIVE_INFINITY,
});

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)

const yearStr = useTimeSync({
  idealRefreshIntervalMs: 3_000,
  select: (date) => date.getFullYear()
});

With explicit type parameter

const yearStr = useTimeSync<string>({
  idealRefreshIntervalMs: 3_000,
  select: (date) => date.getFullYear()
});

@buenos-nachos buenos-nachos self-assigned this Apr 28, 2025
@Emyrk
Copy link
Member

Emyrk commented Apr 28, 2025

@Parkreiner does this have any relation to the Time Variance Authority (TVA) in the Marvel Universe?

@buenos-nachos
Copy link
Contributor Author

@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)

@buenos-nachos buenos-nachos changed the title refactor(site): create centralized time authority for codebase refactor(site): expose time values in render functions as centralized, pure state Apr 28, 2025
@buenos-nachos buenos-nachos changed the title refactor(site): expose time values in render functions as centralized, pure state refactor(site): expose time values in render functions as centralized, deterministic state May 8, 2025
@buenos-nachos buenos-nachos changed the title refactor(site): expose time values in render functions as centralized, deterministic state refactor(site): centralize time values in render functions as deterministic state May 8, 2025
@github-actions github-actions bot added the stale This issue is like stale bread. label May 17, 2025
@github-actions github-actions bot closed this May 20, 2025
@buenos-nachos buenos-nachos reopened this May 20, 2025
@buenos-nachos buenos-nachos removed the stale This issue is like stale bread. label May 20, 2025
@github-actions github-actions bot added the stale This issue is like stale bread. label May 28, 2025
@github-actions github-actions bot closed this Jun 1, 2025
@github-actions github-actions bot deleted the mes/use-time-2 branch November 10, 2025 00:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale This issue is like stale bread.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants