mirror of
https://github.com/kennethnym/aris.git
synced 2026-04-01 07:31:17 +01:00
feat: runtime provider hotswap (#82)
Add ability to replace a FeedSourceProvider at runtime and propagate the new source to all active (and pending) user sessions, invalidating their feed caches. Co-authored-by: Ona <no-reply@ona.com>
This commit is contained in:
@@ -97,23 +97,33 @@ export class FeedEngine<TItems extends FeedItem = FeedItem> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a FeedSource. Invalidates the cached graph.
|
||||
* Registers a FeedSource. Invalidates the cached graph and feed cache.
|
||||
*/
|
||||
register<TItem extends FeedItem>(source: FeedSource<TItem>): FeedEngine<TItems | TItem> {
|
||||
this.sources.set(source.id, source)
|
||||
this.graph = null
|
||||
this.invalidateCache()
|
||||
return this as FeedEngine<TItems | TItem>
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a FeedSource by ID. Invalidates the cached graph.
|
||||
* Unregisters a FeedSource by ID. Invalidates the cached graph and feed cache.
|
||||
*/
|
||||
unregister(sourceId: string): this {
|
||||
this.sources.delete(sourceId)
|
||||
this.graph = null
|
||||
this.invalidateCache()
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the cached feed result so the next access triggers a fresh refresh.
|
||||
*/
|
||||
invalidateCache(): void {
|
||||
this.cachedResult = null
|
||||
this.cachedAt = null
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a post-processor. Processors run in registration order
|
||||
* after items are collected, on every update path.
|
||||
@@ -249,6 +259,13 @@ export class FeedEngine<TItems extends FeedItem = FeedItem> {
|
||||
this.cleanups = []
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the engine is currently running reactive subscriptions.
|
||||
*/
|
||||
isStarted(): boolean {
|
||||
return this.started
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current accumulated context.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user