mirror of
https://github.com/kennethnym/aris.git
synced 2026-03-20 00:51:20 +00:00
refactor: make fetchContext required on FeedSource
Sources that cannot provide context now return null instead of omitting the method. The engine checks the return value rather than method existence. Co-authored-by: Ona <no-reply@ona.com>
This commit is contained in:
@@ -36,6 +36,13 @@ import type { FeedItem } from "./feed"
|
||||
* return createWeatherFeedItems(ctx.weather)
|
||||
* },
|
||||
* }
|
||||
*
|
||||
* // TFL source - no context to provide
|
||||
* const tflSource: FeedSource<TflFeedItem> = {
|
||||
* id: "tfl",
|
||||
* fetchContext: async () => null,
|
||||
* fetchItems: async (ctx) => { ... },
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
export interface FeedSource<TItem extends FeedItem = FeedItem> {
|
||||
@@ -58,8 +65,9 @@ export interface FeedSource<TItem extends FeedItem = FeedItem> {
|
||||
/**
|
||||
* Fetch context on-demand.
|
||||
* Called during manual refresh or initial load.
|
||||
* Return null if this source cannot provide context.
|
||||
*/
|
||||
fetchContext?(context: Context): Promise<Partial<Context>>
|
||||
fetchContext(context: Context): Promise<Partial<Context> | null>
|
||||
|
||||
/**
|
||||
* Subscribe to reactive feed item updates.
|
||||
|
||||
Reference in New Issue
Block a user