Skip to content

feat: add createExternalStore utility and ClockProvider#195

Open
gcutrini wants to merge 1 commit intomainfrom
feature/external-store-clock-context
Open

feat: add createExternalStore utility and ClockProvider#195
gcutrini wants to merge 1 commit intomainfrom
feature/external-store-clock-context

Conversation

@gcutrini
Copy link
Contributor

@gcutrini gcutrini commented Feb 5, 2026

Add a generic external store factory (createExternalStore) using useSyncExternalStore that lets components subscribe to frequently-updating data sources without unnecessary re-renders.

Includes a pre-built clock store (ClockProvider, useClock, useClockSelector) wrapping the existing Clock component. This enables projects to move clock state out of Redux, eliminating per-second re-renders of all connected components.

API

  • createExternalStore(name){ Provider, useValue, useSelector }
  • useValue() — re-renders on every emit
  • useSelector(compute, isEqual) — re-renders only when the computed result changes

Clock usage

import { ClockProvider, useClock, useClockSelector } from 'openstack-uicore-foundation/lib/components/clock-context';

<ClockProvider timezone={summit.time_zone_id}>
  <App />
</ClockProvider>

const nowUtc = useClock(); // re-renders every second
const allowedTickets = useClockSelector(compute, isEqual); // re-renders only on change

ref: https://app.clickup.com/t/86b8dm4da

Add a generic external store factory (createExternalStore) using
useSyncExternalStore that allows components to subscribe to
frequently-updating data sources without causing unnecessary re-renders.

Includes a pre-built clock store (ClockProvider, useClock,
useClockSelector) that wraps the existing Clock component, enabling
projects to move clock state out of Redux and eliminate per-second
re-renders of all connected components.
@gcutrini gcutrini requested a review from smarcet February 5, 2026 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant