Type Parameters

  • E

Hierarchy

Constructors

Properties

_query: string = ''

The current query state.

config: StoreConfig

The configuration for the store.

entries: Map<string, E> = ...

Primary index for the stores elements.

idEntries: Map<string, E> = ...

The element entries that are keyed by an id generated on the server.

notify: ReplaySubject<E[]> = ...

Create notifications that broacast the entire set of entries.

notifyDelta: ReplaySubject<Delta<E>> = ...

Create notifications that broacast store or slice delta state changes.

notifyQuery: ReplaySubject<string> = ...

Notifies observers of the store query.

obs: Observable<E[]> = ...

An Observable<E[]> reference to the entities in the store or Slice instance.

Accessors

  • get GUID_KEY(): string
  • The current guid key for the EStore instance.

    Returns string

    this.config.guidKey;

  • get ID_KEY(): string
  • The current id key for the EStore instance.

    Returns string

    this.config.idKey;

  • get query(): string
  • Returns string

    A snapshot of the query state.

  • set query(query): void
  • Sets the current query state and notifies observers.

    Parameters

    • query: string

    Returns void

Methods

  • Snapshot of all entries.

    Returns E[]

    Snapshot array of all the elements the entities the store contains.

    Example: Observe a snapshot of all the entities in the store.

    let selectedTodos:Todo[] = source.allSnapshot();
    
  • Returns true if the entries contain the identified instance.

    Parameters

    • target: string | E

      Either an instance of type E or a guid identifying the instance.

    Returns boolean

    true if the instance identified by the guid exists, false otherwise.

    Example

    <pre>
    let contains:boolean = source.contains(guid);
    </pre>
  • Returns true if the entries contain the identified instance.

    Parameters

    • target: string | E

      Either an instance of type E or a id identifying the instance.

    Returns boolean

    true if the instance identified by the id exists, false otherwise.

    Example

    <pre>
    let contains:boolean = source.contains(guid);
    </pre>
  • Returns the number of entries contained.

    Parameters

    • Optional p: Predicate<E>

      The predicate to apply in order to filter the count

    Returns Observable<number>

  • Returns a snapshot of the number of entries contained in the store.

    Parameters

    • Optional p: Predicate<E>

      The predicate to apply in order to filter the count

    Returns number

  • Calls complete on all ReplaySubject instances.

    Call destroy when disposing of the store.

    Returns void

  • Compare entities by GUID

    Parameters

    • e1: any

      The first entity

    • e2: any

      The second entity

    Returns boolean

    true if the two entities have equal GUID ids

    Example: Compare todo1 with todo2 by gid.

    if (equalsByGUID(todo1, todo2)){...};
    
  • Compare entities by ID

    Parameters

    • e1: any

      The first entity

    • e2: any

      The second entity

    Returns boolean

    true if the two entities have equal ID ids

    Example: Compare todo1 with todo2 by id.

    if (equalsByID(todo1, todo2)){...};
    
  • Find and return the entity identified by the GUID parameter if it exists and return it.

    Parameters

    • guid: string

    Returns undefined | E

    The entity instance if it exists, null otherwise

  • Find and return the entity identified by the ID parameter if it exists and return it.

    Parameters

    • id: string

    Returns undefined | E

    The entity instance if it exists, null otherwise

  • Check whether the store is empty.

    Returns Observable<boolean>

    A hot Observable that indicates whether the store is empty.

    Example

    const empty$:Observable<boolean> = source.isEmpty();
    
  • Check whether the store is empty.

    Returns boolean

    A snapshot that indicates whether the store is empty.

    Example

    const empty:boolean = source.isEmptySnapshot();
    
  • Call all the notifiers at once.

    Parameters

    Returns void

  • Observe store state changes.

    Parameters

    • Optional sort: ((a, b) => number)

      Optional sorting function yielding a sorted observable.

        • (a, b): number
        • Parameters

          • a: any
          • b: any

          Returns number

    Returns Observable<E[]>

    Example

    let todos$ = source.observe();
    //or with a sort by title function
    let todos$ = source.observe((a, b)=>(a.title > b.title ? -1 : 1));
  • Observe delta updates.

    Returns Observable<Delta<E>>

    Example

    let todos$ = source.observeDelta();
    
  • Observe the query.

    Returns Observable<string>

    Example

    <pre>
    let query$ = source.observeQuery();
    </pre>
  • Snapshot of the entries that match the predicate.

    Parameters

    • p: Predicate<E>

      The predicate used to query for the selection.

    Returns E[]

    A snapshot array containing the entities that match the predicate.

    Example: Select all the Todo instances where the title length is greater than 100.

    let todos:Todo[]=store.select(todo=>todo.title.length>100);
    

Generated using TypeDoc