mirror of
https://github.com/kennethnym/aris.git
synced 2026-02-02 13:11:17 +00:00
feat(core): add FeedController orchestration layer
Adds orchestration for feed reconciliation with context-driven updates: - FeedController: holds context, debounces updates, reconciles sources - ContextBridge: bridges context providers to controller - ContextProvider: reactive + on-demand context value interface - Branded ContextKey<T> for type-safe context keys Moves source files to src/ directory and consolidates tests into integration test. Co-authored-by: Ona <no-reply@ona.com>
This commit is contained in:
35
packages/aris-core/src/context-provider.ts
Normal file
35
packages/aris-core/src/context-provider.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Provides context values reactively and on-demand.
|
||||
*
|
||||
* Implementations push updates when values change (reactive) and
|
||||
* return current values when requested (for manual refresh).
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* class LocationProvider implements ContextProvider<Location> {
|
||||
* readonly key = LocationKey
|
||||
*
|
||||
* onUpdate(callback: (value: Location) => void): () => void {
|
||||
* const watchId = navigator.geolocation.watchPosition(pos => {
|
||||
* callback({ lat: pos.coords.latitude, lng: pos.coords.longitude, accuracy: pos.coords.accuracy })
|
||||
* })
|
||||
* return () => navigator.geolocation.clearWatch(watchId)
|
||||
* }
|
||||
*
|
||||
* async getCurrentValue(): Promise<Location> {
|
||||
* const pos = await getCurrentPosition()
|
||||
* return { lat: pos.coords.latitude, lng: pos.coords.longitude, accuracy: pos.coords.accuracy }
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
export interface ContextProvider<T = unknown> {
|
||||
/** The context key this provider populates */
|
||||
readonly key: string
|
||||
|
||||
/** Subscribe to value changes. Returns cleanup function. */
|
||||
onUpdate(callback: (value: T) => void): () => void
|
||||
|
||||
/** Get current value on-demand (used for manual refresh). */
|
||||
getCurrentValue(): Promise<T>
|
||||
}
|
||||
Reference in New Issue
Block a user