Options
All
  • Public
  • Public/Protected
  • All
Menu

BusStore is a stateful in memory cache for objects. All state changes (any time the cache is modified) will broadcast that updated object to any subscribers of the BusStore online for those specific objects or all objects of a certain type and state changes.

Type parameters

  • T

Hierarchy

  • BusStore

Index

Methods

  • allValues(): T[]
  • allValuesAsMap(): Map<string, T>
  • get(id: string): T
  • Retrieve an object from the cache

    Parameters

    • id: string

      the string ID of the object you wish to get.

    Returns T

    the object you're looking for.

  • initialize(): void
  • Flip an internal bit to set the cache to ready, notify all watchers.

    Returns void

  • isGalacticStore(): boolean
  • Send a mutation command to any subscribers handling mutations.

    Type parameters

    • V

    • M

    • S

    • E

    Parameters

    • value: V

      to be mutated

    • mutationType: M

      the type of the mutation

    • successHandler: MessageFunction<S>

      provide object S to mutator function on successful mutation.

    • Optional errorHandler: MessageFunction<E>

      provide object E to mutator function on error.

    Returns boolean

    true if mutation command was placed in stream

  • onAllChanges<S>(...stateChangeType: S[]): StoreStream<T, any>
  • Subscribe to state changes for all objects of a specific type and state change

    Type parameters

    • S

    Parameters

    • Rest ...stateChangeType: S[]

      the state change type you with to listen to

    Returns StoreStream<T, any>

    stream that will tick the object you're online for.

  • onChange<S>(id: string, ...stateChangeType: S[]): StoreStream<T, any>
  • Subscribe to state changes for a specific object.

    Type parameters

    • S

    Parameters

    • id: string

      the ID of the object you wish to receive updates.

    • Rest ...stateChangeType: S[]

      the state change type you wish to listen to

    Returns StoreStream<T, any>

    stream that will tick the object you're online for.

  • onMutationRequest<M>(objectType: T, ...mutationType: M[]): MutateStream<T, any, any>
  • Subscribe to mutation requests via mutate()

    Type parameters

    • M = any

    Parameters

    • objectType: T

      the object you want to listen for.

    • Rest ...mutationType: M[]

      optional mutation type

    Returns MutateStream<T, any, any>

    stream that will tick mutation requests you're online for.

  • populate(items: Map<string, T>): boolean
  • Populate the cache with a collection of objects and their ID's.

    Parameters

    • items: Map<string, T>

      a Map of your UUID's mapped to your Objects.

    Returns boolean

    if the cache has already been populated (has objects), will return false. This method has no effect for galactic stores.

  • put<S>(id: string, value: T, state: S): void
  • Place an object into the cache, will broadcast to all subscribers online for state changes.

    Type parameters

    • S

    Parameters

    • id: string

      string ID of your object, UUID is highly recommended.

    • value: T

      the object you wish to cache

    • state: S

      the state change event you want to broadcast with this action (created, updated etc).

    Returns void

  • refreshApiDelay(): void
  • Restart auto-reload timer.

    This method has no effect for galactic stores.

    Returns void

  • reloadStore(): void
  • Reload store with refresh service call.

    This method has no effect for galactic stores.

    Returns void

  • remove<S>(id: string, state: S): boolean
  • Remove/delete an object into the cache.

    Type parameters

    • S

    Parameters

    • id: string

      The string ID of the object you wish to remove.

    • state: S

      you want to be sent to subscribers notifying cache deletion.

    Returns boolean

    true if it was removed, false if not.

  • reset(): void
  • Will wipe all data out, in case you need a clean slate.

    Returns void

  • setAutoReloadServiceTrigger(serviceCallFunction: Function): void
  • Set lambda that is used to auto-reload this store.

    Parameters

    • serviceCallFunction: Function

      function should encapsulate a service call.

      This method has no effect for galactic stores.

    Returns void

  • startAutoReload(timeToLiveInMs: number): void
  • Start automatic reload. The store will refetch its data (using setAutoReloadServiceTrigger). The store is considered stale once the TTL has passed.

    Parameters

    • timeToLiveInMs: number

      how long to hold data in the store before refetching. (default is 10 seconds)

      This method has no effect for galactic stores.

    Returns void

  • stopAutoReload(): void
  • Stop Store from auto-refreshing.

    This method has no effect for galactic stores.

    Returns void

  • Notify when the cache has been initialize (via populate() or initialize()

    Parameters

    • readyFunction: MessageFunction<Map<string, T>>

      that accepts the entire cache as a map.

    Returns void

Generated using TypeDoc