Context
sourceA context contains one view per model defined by the schema. It may be either the root context, in which case it functions as the store of all records, or it may be a user context, in which case it indexes the records that are visible within that user's sandbox.
Constructors
new Context(schema: Schema, userId: Id<User>): Contextsource
Properties
alreadyDisposed: booleansource
baseViews: Map<string, Handle<View<Model<string>>>>source
schema: Schemasource
userId: Id<User>source
Methods
Static methods
forSchema<S extends Schema<S>>(schema: S): Handlesource
Get the root context for the given schema.
getDefault(): Handlesource
Get the root context for the default schema.
getPersistent(schema: Schema, userId: Id<User>): Handlesource
getTemporary(userId: Id<User>): Contextsource
getTemporary<S extends Schema<S>>(schema: S, userId: Id<User>): Contextsource
resetDefault(): voidsource
Clear and rebuild the root context for the default schema. Used for unit tests.
Instance methods
[custom](): stringsource
[iterator](): IterableIterator<readonly [string, View<Model<string>>]>source
assertNotDisposed(): voidsource
consumeFrom(source: Iterable<Model<string>>): voidsource
Consumes all records from an iterable source. Calls consumeRecord for each record received.
consumeRecord(record: Model<string>): voidsource
Consumes a record. This will fire a consume event from the dispatcher for that model, which will cause it to be processed by any views that depend on that model. Note that this causes the record to be ingested by all contexts for this schema, not just this specific context.
dispose(): voidsource
getDispatcherForModel(model: string | ModelType<Model<string>>): ModelDispatchersource
Gets the event dispatcher for a model. The dispatcher is shared between all contexts for that schema.
getRootViewForModel<T extends Model<string, T>>(model: ModelType<T>): Viewsource
Gets the root view for a model of this context. If this is a sandbox context, it is the view that contains the index of all records the user can view. If this is a root context, the view contains all records for that model that have been received by this process.
getRootViewForModel(model: string): Viewsource
getSequenceNumberForModel(model: string | ModelType<Model<string>>): numbersource
reset(): voidsource
Wipes all of the data in the context.
toString(): stringsource