UNPKG

@politie/sherlock-utils

Version:

Utility functions that are designed to work with Sherlock. His toolbelt.

20 lines (19 loc) 793 B
import { PullDataSource } from '@politie/sherlock'; /** * Lazy PullDataSource that is based on a plain javascript function that has to supply the value when someone subscribes to this * datasource. */ export declare class FunctionDataSource<T> extends PullDataSource<T> { private readonly fn; constructor(fn: () => T); /** * Required function that calculates the current value for this datasource. Will be called once everytime * `get()` is called when not connected. When connected, it will be called once and then only whenever `checkForChanges()` * was called. */ calculateCurrentValue(): T; /** * Update the currently cached value of this datasource (only when connected) and notify observers when neccessary. */ changed(): void; }