Store constructor (Initialization with element is optional)
perform initial notification to all observers, such that function like {@link combineLatest}{} will execute at least once.
The current loading state. Use loading when fetching new
data for the store. The default loading state is true
.
This is such that if data is fetched asynchronously in a service, components can wait on loading notification before attempting to retrieve data from the service.
Loading could be based on a composite response. For example
when the stock and mutual funds have loaded, set loading to false
.
The current query state.
The current searching
state. Use searching
for example to display a spinnner
when performing a search.
The default searching
state is false
.
Map
of active entties. The instance is public and can be used
directly to add and remove active entities, however we recommend
using the addActive and deleteActive methods.
The configuration for the store.
Primary index for the stores elements.
The element entries that are keyed by an id generated on the server.
Observable of errors occurred during a load request.
Create notifications that broacast the entire set of entries.
Notifies observers when the store is empty.
Create notifications that broacast store or slice delta state changes.
Notifies observers when the store is empty.
Notifies observers of changes to the number of entries in the store.
Notifies observers when the store is loading.
This is a common pattern found when implementing
Observable
data sources.
Notifies observers of the store query.
Notifies observers that a search is in progress.
This is a common pattern found when implementing
Observable
data sources.
An Observable<E[]> reference so that
Observable of errors occurred during a search request.
Store slices
The current guid key for the EStore instance.
this.config.guidKey;
The current id key for the EStore instance.
this.config.idKey;
Sets the current loading state and notifies observers.
A snapshot of the loading state.
Sets the current loading state and notifies observers.
A snapshot of the loading state.
Sets the current query state and notifies observers.
A snapshot of the query state.
Sets the current query state and notifies observers.
A snapshot of the query state.
Sets the current searching state and notifies observers.
A snapshot of the searching state.
Sets the current searching state and notifies observers.
A snapshot of the searching state.
Add multiple entity entities to active.
If the entity is not contained in the store it is added
to the store before it is added to active
.
Also we clone the map prior to broadcasting it with
notifyActive
to make sure we will trigger Angular
change detection in the event that it maintains
a reference to the active
state Map
instance.
Adds a slice to the store and keys it by the slices label.
Snapshot of all entries.
Snapshot array of all the elements the entities the store contains.
Clear / reset the active entity map.
Also we clone the map prior to broadcasting it with
notifyActive
to make sure we will trigger Angular
change detection in the event that it maintains
a reference to the active
state Map
instance.
Returns true if the entries contain the identified instance.
Either an instance of type E
or a guid
identifying the instance.
true if the instance identified by the guid exists, false otherwise.
Returns true if the entries contain the identified instance.
Either an instance of type E
or a id
identifying the instance.
true if the instance identified by the id
exists, false otherwise.
Returns the number of entries contained.
The predicate to apply in order to filter the count
Returns a snapshto of the number of entries contained in the store.
The predicate to apply in order to filter the count
Delete (Update) the array of elements.
Delete N elements.
Delete an entity as active.
Also we clone the map prior to broadcasting it with
notifyActive
to make sure we will trigger Angular
change detection in the event that it maintains
a reference to the active
state Map
instance.
If the entity has the id
key initialized with a value,
then also delete the entity to the idEntries
.
The element to be added to the idEntries
.
Delete N elements.
Calls complete on all {@link BehaviorSubject} instances.
Call destroy when disposing of the store.
Compare entities by GUID
The first entity
The second entity
true if the two entities have equal GUID ids
Compare entities by ID
The first entity
The second entity
true if the two entities have equal ID ids
Find and return the entity identified by the GUID parameter if it exists and return it.
The entity instance if it exists, null otherwise
Find and return the entity identified by the ID parameter if it exists and return it.
The entity instance if it exists, null otherwise
Get a slice
The label identifying the slice
Check whether the store is empty.
A hot {@link Observable} that indicates whether the store is empty.
Check whether the store is empty.
A snapshot that indicates whether the store is empty.
Call all the notifiers at once.
Observe store state changes.
Optional sorting function yielding a sorted observable.
Observe the active entity.
Observe delta updates.
Observe loading.
Notfiies when loading has completed.
Observe the query.
Observe searching.
Notfiies when searching has completed.
Post (Add a new) element to the store.
Post (Add) an array of elements to the store.
Post elements to the store.
Put (Update) an element.
Put (Update) the array of elements.
Put (Update) an element or add an element that was read from a persistence source and thus already has an assigned global id`.
Remove a slice
The label identifying the slice
Resets the store and all contained slice instances to empty. Also perform delta notification that sends all current store entries. The ActionType.RESET code is sent with the delta notification. Slices send their own delta notification.
Snapshot of the entries that match the predicate.
The predicate used to query for the selection.
A snapshot array containing the entities that match the predicate.
Toggles the entity:
If the store contains the entity it will be deleted. If the store does not contains the entity, it is added.
If the entity has the id
key initialized with a value,
then also add the entity to the idEntries
.
The element to be added to the idEntries
.
Generated using TypeDoc
This
todoFactory
code will be used to illustrate the API examples. The following utilities are used in the tests and the API Typedoc examples contained here.Utilities for API Examples
export const enum TodoSliceEnum { COMPLETE = "Complete", INCOMPLETE = "Incomplete" } export class Todo { constructor(public complete: boolean, public title: string,public gid?:string, public id?:string) {} } export let todos = [new Todo(false, "You complete me!"), new Todo(true, "You completed me!")]; export function todosFactory():Todo[] { return [new Todo(false, "You complete me!"), new Todo(true, "You completed me!")]; }