UNPKG

@ztimson/momentum

Version:

Client library for momentum

43 lines 1.4 kB
import { PathEvent } from '@ztimson/utils'; import { AssetController } from './asset-controller'; import { Momentum } from './momentum'; import { Unsubscribe } from './core'; /** Momentum variable */ export type Setting<T> = { /** Variable name */ readonly _id: string; /** Variable value */ value: T; /** Visible without authenticating */ public?: boolean; /** Momentum variable, cannot be deleted */ readonly system?: boolean; }; export type SettingsOptions = { /** save to local storage */ persist?: boolean; }; export declare class Settings extends AssetController<Setting<any>> { protected momentum: Momentum; constructor(momentum: Momentum); /** * Get all schemas organized into a map * @param {boolean} reload Reload instead of using cache * @return {Promise<TreeNode<Schema>[]>} Schemas as nested tree */ map(reload?: boolean): Promise<{ [key: string]: any; }>; /** * Subscribe to live updates with optional callback * @param {(schema: Schema[]) => any} callback Receives latest data * @param opts path - scope events, map - return as map or array * @return {() => void} */ sync(callback?: (event: PathEvent, value: any) => any, opts?: { path?: string; map?: boolean; reload?: boolean; }): Unsubscribe; } //# sourceMappingURL=settings.d.ts.map