mirror of
https://github.com/kennethnym/aris.git
synced 2026-03-20 00:51:20 +00:00
Replace per-source services (LocationService, WeatherService, TflService, FeedEngineService) with a single UserSessionManager that owns all per-user state. Source creation is delegated to thin FeedSourceProvider implementations per source type. Co-authored-by: Ona <no-reply@ona.com>
25 lines
563 B
TypeScript
25 lines
563 B
TypeScript
import { FeedEngine, type FeedSource } from "@aris/core"
|
|
|
|
export class UserSession {
|
|
readonly engine: FeedEngine
|
|
private sources = new Map<string, FeedSource>()
|
|
|
|
constructor(sources: FeedSource[]) {
|
|
this.engine = new FeedEngine()
|
|
for (const source of sources) {
|
|
this.sources.set(source.id, source)
|
|
this.engine.register(source)
|
|
}
|
|
this.engine.start()
|
|
}
|
|
|
|
getSource<T extends FeedSource>(sourceId: string): T | undefined {
|
|
return this.sources.get(sourceId) as T | undefined
|
|
}
|
|
|
|
destroy(): void {
|
|
this.engine.stop()
|
|
this.sources.clear()
|
|
}
|
|
}
|