/** * Contexts are useful for keeping track of the origin of subscribes. */ import { Model } from './Model'; import { CollectionCounter } from './CollectionCounter'; declare module './Model' { interface Model { /** * Creates a new child model with a specific named data-loading context. The * child model has the same scoped path as this model. * * Contexts are used to track counts of fetches and subscribes, so that all * data relating to a context can be unloaded all at once, without having to * manually track loaded data. * * Contexts are in a global namespace for each root model, so calling * `model.context(contextId)` from two different places will return child * models that both refer to the same context. * * @param contextId - context id * * @see https://derbyjs.github.io/derby/models/contexts */ context(contextId: string): ChildModel; /** * Get the named context or create a new named context if it doesnt exist. * * @param contextId context id * * @see https://derbyjs.github.io/derby/models/contexts */ getOrCreateContext(contextId: string): Context; /** * Set the named context to use for this model. * * @param contextId context id * * @see https://derbyjs.github.io/derby/models/contexts */ setContext(contextId: string): void; /** * Unloads data for this model's context, or for a specific named context. * * @param contextId - optional context to unload; defaults to this model's context * * @see https://derbyjs.github.io/derby/models/contexts */ unload(contextId?: string): void; /** * Unloads data for all model contexts. * * @see https://derbyjs.github.io/derby/models/contexts */ unloadAll(): void; _contexts: Contexts; } } export declare class Contexts { toJSON(): Record; } declare class FetchedQueries { } declare class SubscribedQueries { } export declare class Context { model: Model; id: string; fetchedDocs: CollectionCounter; subscribedDocs: CollectionCounter; createdDocs: CollectionCounter; fetchedQueries: FetchedQueries; subscribedQueries: SubscribedQueries; constructor(model: Model, id: string); toJSON(): { fetchedDocs: {}; subscribedDocs: {}; createdDocs: {}; }; fetchDoc(collectionName: any, id: any): void; subscribeDoc(collectionName: any, id: any): void; unfetchDoc(collectionName: any, id: any): void; unsubscribeDoc(collectionName: any, id: any): void; createDoc(collectionName: any, id: any): void; fetchQuery(query: any): void; subscribeQuery(query: any): void; unfetchQuery(query: any): void; unsubscribeQuery(query: any): void; unload(): void; } export {};