jinaga
Version:
Data management for web and mobile applications.
45 lines • 2.6 kB
TypeScript
import { DistributionEngine } from "../distribution/distribution-engine";
import { FeedResponse } from "../http/messages";
import { Specification } from "../specification/specification";
import { FactEnvelope, FactReference, Storage } from "../storage";
export interface Network {
feeds(start: FactReference[], specification: Specification): Promise<string[]>;
fetchFeed(feed: string, bookmark: string): Promise<FeedResponse>;
streamFeed(feed: string, bookmark: string, onResponse: (factReferences: FactReference[], nextBookmark: string) => Promise<void>, onError: (err: Error) => void): () => void;
load(factReferences: FactReference[]): Promise<FactEnvelope[]>;
}
export declare class NetworkNoOp implements Network {
feeds(start: FactReference[], specification: Specification): Promise<string[]>;
fetchFeed(feed: string, bookmark: string): Promise<FeedResponse>;
streamFeed(feed: string, bookmark: string, onResponse: (factReferences: FactReference[], nextBookmark: string) => Promise<void>, onError: (err: Error) => void): () => void;
load(factReferences: FactReference[]): Promise<FactEnvelope[]>;
}
export declare class NetworkDistribution implements Network {
private readonly distributionEngine;
private readonly user;
private feedCache;
constructor(distributionEngine: DistributionEngine, user: FactReference | null);
feeds(start: FactReference[], specification: Specification): Promise<string[]>;
fetchFeed(feed: string, bookmark: string): Promise<FeedResponse>;
streamFeed(feed: string, bookmark: string, onResponse: (factReferences: FactReference[], nextBookmark: string) => Promise<void>, onError: (err: Error) => void): () => void;
load(factReferences: FactReference[]): Promise<FactEnvelope[]>;
}
export declare class NetworkManager {
private readonly network;
private readonly store;
private readonly notifyFactsAdded;
private readonly feedsCache;
private readonly activeFeeds;
private fetchCount;
private currentBatch;
private subscribers;
private readonly feedRefreshIntervalSeconds;
constructor(network: Network, store: Storage, notifyFactsAdded: (factsAdded: FactEnvelope[]) => Promise<void>, feedRefreshIntervalSeconds?: number);
fetch(start: FactReference[], specification: Specification): Promise<void>;
subscribe(start: FactReference[], specification: Specification): Promise<string[]>;
unsubscribe(feeds: string[]): void;
private getFeedsFromCache;
private removeFeedsFromCache;
private processFeed;
}
//# sourceMappingURL=NetworkManager.d.ts.map