Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BaseManager<H, D, E, V, K>

Type parameters

  • H

  • D

  • E

  • V

  • K

Hierarchy

Index

Constructors

Properties

Methods

Constructors

constructor

  • new BaseManager<H, D, E, V, K>(client: Client, hold: H, iterable?: (D | V)[], extras?: E): BaseManager<H, D, E, V, K>
  • Type parameters

    • H: new (client: Client, data: any, ...args: any[]) => Identifiable<K>

    • D = H extends new (client: Client, data: R, ...args: any[]) => any ? R : never

    • E = H extends new (client: Client, data: any, ...args: R) => any ? R : never

    • V = H extends new (client: Client, data: any, ...args: any[]) => R ? R : never

    • K = V extends Identifiable<R> ? R : never

    Parameters

    • client: Client
    • hold: H
    • Optional iterable: (D | V)[]
    • Optional extras: E

    Returns BaseManager<H, D, E, V, K>

Properties

Readonly cache

cache: Map<K, V> = ...

The cache of the manager.

Readonly client

client: Client

Protected Optional Readonly extras

extras: E

Protected Readonly hold

hold: H

Methods

Abstract add

  • add(data: D | V, cache: boolean): V
  • Adds the data to the cache (or return the cached element, if cache is true).

    Parameters

    • data: D | V

      The data to add.

    • cache: boolean

      If the data should be cached (or cached data patched), true by default.

    Returns V

    The resolved data.

Optional fetch

  • fetch(key: K, cache?: boolean, checkCache?: boolean): Promise<undefined | V>
  • Fetches the data from Pi Network APIs (or return the cached element, if cache is true).

    Parameters

    • key: K

      The data's key (id, etc.).

    • Optional cache: boolean

      If the data should be cached (or cached data patched), true by default.

    • Optional checkCache: boolean

      If the cached data should be returned (if it exists) rather than fetching the data, true by default.

    Returns Promise<undefined | V>

    The the fetched (or cached) data, or undefined if not found.

resolve

  • resolve(key: K): undefined | V
  • Resolves the data by its key from the cache.

    Parameters

    • key: K

      The data's key (id, etc.).

    Returns undefined | V

    The cached data or undefined if not found.

Generated using TypeDoc