UNPKG

@traxjs/trax

Version:

Reactive state management

83 lines (82 loc) 3.14 kB
import { TraxInternalProcessor } from "./processor"; import { Trax, TraxObjectType, TraxProcessorId } from "./types"; /** * Meta-data object attached to each trax object (object, array, dictionary, processor, store) */ interface TraxMd { /** The trax unique id */ id: string; /** The object type */ type: TraxObjectType; /** Store that the object belongs to. Empty string for root stores */ storeId: string; /** * Used by data objects (objects / array / dictionary) to track processors that have a dependency on their properties */ propListeners?: Set<TraxInternalProcessor>; /** * Tell if the object has listeners outside the contentProcessors */ hasExternalPropListener: boolean; /** * Tell when the lazy processors are being checked */ processingLazyCheck: boolean; /** * Map of computed properties and their associated processor * Allows to detect if a computed property is illegaly changed */ computedProps?: { [propName: string]: TraxProcessorId | undefined; }; /** * Property used when the trax object is a collection and its content is set by a processor * through updateArray or updateDictionary * In this case computedProps should be undefined */ computedContent?: TraxProcessorId; /** * Content processors associated to this object (can be lazy or eager) * These processors are created through store.add() or store.init() and will be disposed * when the object is removed from the store */ contentProcessors?: TraxInternalProcessor[]; /** * Auto-wrap level / Ref props computation * Tell how sub-objects properties should be handled and if sub-objects should be automatcially wrapped or if * they should be considered as references * If level is 1, properties will be considered as references and won't be wrapped * If level is >1, wrapped properties will be passed a decremented level (e.g. x-1 if x is the current level) * Default = 0 (sub-object will be wrapped) */ awLevel?: number; /** * Number of properties set on an object - only used for objects used as dictionaries */ dictSize?: number; } /** * Register a new processor as listener * @param p the processor to register * @param md the meta data object to update (update will be ignored if not provided) */ export declare function registerMdPropListener(p: TraxInternalProcessor, md?: TraxMd): void; /** * Unregister a processor from the meta-data listener * @param p the processor to register * @param md the meta data object to update (update will be ignored if not provided) */ export declare function unregisterMdPropListener(p: TraxInternalProcessor, md?: TraxMd): void; /** * Get the trax meta data associated to an object * @param o * @returns */ export declare function tmd(o: any): TraxMd | undefined; /** * Create a trax environment. This function must only be used in test environments: * applications must use the global trax object instead * @see trax */ export declare function createTraxEnv(): Trax; export {};