import { EventManager, EventListener, EventSubscriptionCancellation } from '@webprovisions/platform'; import { Entry, CommandMessage } from './messages'; import EntryStream from './entry-stream'; import Middleware from './middleware'; export declare enum DataSourceState { Disconnected = "disconnected", Connecting = "connecting", Connected = "connected", Disconnecting = "disconnecting" } /** * Provides functions and events for manipulating and observing * an underlying entry stream. */ export default class DataSource { parent?: DataSource | undefined; entries: Entry[] | null; stream: EntryStream; events: EventManager; middleware: Middleware[]; state: DataSourceState; constructor(events?: EventManager, parent?: DataSource | undefined); /** * Gets the root `DataSource` object for the current instance. */ getRootInstance(): DataSource; /** * Registers an event listener on the root `DataSource` instance for when * the underlying entry stream is changed. */ onChange(handler: EventListener): EventSubscriptionCancellation; /** * Connects the `DataSource` and executes corresponding middleware. * @param args Optional connection arguments. */ connect(args?: any): Promise; /** * Disconnects the `DataSource` and executes corresponding middleware. * @param args Optional disconnection arguments. */ disconnect(args?: any): Promise; /** * Dispatches a command on the `DataSource` and executes corresponding middleware. */ command(keyOrCommandMessage: (string | CommandMessage), value?: any): Promise; /** * Dispatches an action for an entry in the `DataSource` and executes corresponding middleware. */ respond(entryId: string, label: string, data?: any): Promise; /** * Write new entries to the current `DataSource`. * @param entries Entries to be written. */ write(entries: Entry[]): Promise; /** * Gets an `EntryStream` object containing all items, including * parents, for the current `DataSource`. */ getStream(): EntryStream; /** * Returns the latest processed stream, including data from parents. */ read(optimisticLock?: boolean): Promise; /** * Pushes the local stream up to its parent, if available. */ pushUp(): void; /** * Creates a child `DataSource` instance. */ createChild(): DataSource; } //# sourceMappingURL=data-source.d.ts.map