@mantlebee/ts-data
    Preparing search index...

    Interface IDataSourceBase<TItem>

    The members of a data source that do not depend on its extensions: the state and the read cycle. IDataSource adds the keyed extensions; annotate with that one.

    interface IDataSourceBase<TItem = Any> {
        isReading: boolean;
        items: List<TItem>;
        dispose(): Promise<void>;
        on<TKey extends string>(
            event: TKey,
            handler: EventHandler<DataSourceEvents<TItem>, TKey>,
        ): IDisposable;
        read(): Promise<void>;
    }

    Type Parameters

    • TItem = Any

      Type of the items.

    Hierarchy

    Index
    isReading: boolean

    true from the first read() until the latest one settles: a read superseded by a newer one does not reset it.

    items: List<TItem>

    Items of the latest completed read; a superseded read never sets them.

    • Releases the held resource. Implementations should be safe to call more than once.

      Returns Promise<void>

      a promise that settles once the resource has been released.

    • Registers a handler for an event.

      Type Parameters

      • TKey extends string

        Name of the event to listen to.

      Parameters

      Returns IDisposable

      a subscription; dispose it to remove this single handler.

    • Runs the read cycle and updates items. Rejects with the error of the reader or of an extension, after raising the error event.

      A newer read() (or dispose()) supersedes a running one: the superseded read() rejects with the AbortedException of ts-core, without error event, and its result is discarded. A consumer awaiting read() ignores that rejection with isAbortedException; one that only listens to items and error has nothing to handle.

      Returns Promise<void>

      try {
      await users.read();
      } catch (error) {
      if (!isAbortedException(error)) throw error; // a newer read superseded this one
      }