UNPKG

router-primitives

Version:

A cross-platform application router. Declarative routing by way of layout primitives

82 lines (81 loc) 2.77 kB
export interface IStep { time: number; name: string; info: object; } export interface ITracerThing { isActive: boolean; name: string; startTime: number; steps: IStep[]; postEndSteps: IStep[]; endMessage: string; endTime: number; session: ITracerSession; start: () => void; logStep: (name: IStep['name'], info?: IStep['info']) => void; endWithMessage: (reason: ITracerThing['endMessage']) => void; end: () => void; } export declare type ThingSubscription = (tracerThingInfo: ITracerThing) => any; export interface ITracerManager { pastSessions: ITracerSession[]; currentSessions: { [sessionName: string]: ITracerSession; }; lastSession: ITracerSession; newSession: (name: ITracerSession['name']) => ITracerSession; _moveSessionToFinishedStorage: (session: ITracerSession) => void; } export interface ITracerSession { manager: ITracerManager; isActive: boolean; name: string; startTime: number; endMessage: string; endTime: number; tracerThings: { [tracerThingName: string]: ITracerThing; }; thingSubscriptions: { [thingName: string]: ThingSubscription[]; }; subscribeToThing: (thingName: string, callbackFn: ThingSubscription) => void; removeAllSubscriptions: () => void; notifySubscribersOfThingUpdate: (nameOfUpdatedThing: string) => void; tracerThing: (thingName: string) => ITracerThing; endWithMessage: (message: ITracerSession['endMessage']) => void; end: () => void; } export declare class TracerSession implements ITracerSession { manager: ITracerManager; isActive: boolean; name: string; startTime: number; endMessage: string; endTime: number; tracerThings: { [tracerThingName: string]: ITracerThing; }; thingSubscriptions: { [thingName: string]: ThingSubscription[]; }; constructor(name: ITracerSession['name']); subscribeToThing(thingName: string, callbackFn: ThingSubscription): void; removeAllSubscriptions(): void; notifySubscribersOfThingUpdate(nameOfUpdatedThing: string): void; tracerThing(thingName: string): ITracerThing; endWithMessage(message: ITracerSession['endMessage']): void; end(): void; } export declare class TracerManager implements ITracerManager { pastSessions: ITracerSession[]; currentSessions: { [sessionName: string]: ITracerSession; }; constructor(); get lastSession(): ITracerSession; newSession(name: ITracerSession['name']): ITracerSession; _moveSessionToFinishedStorage(session: ITracerSession): void; } export declare const tracerManager: TracerManager;