UNPKG

1.34 kBTypeScriptView Raw
1/**
2 * Disposes of all the internal Observables created by invocations of `now()`.
3 *
4 * The use case for this is to ensure that unit tests can run independent of each other.
5 * You should not call this in regular application code.
6 *
7 * @example
8 * afterEach(() => {
9 * utils.resetNowInternalState()
10 * })
11 */
12export declare function resetNowInternalState(): void;
13/**
14 * Returns the current date time as epoch number.
15 * The date time is read from an observable which is updated automatically after the given interval.
16 * So basically it treats time as an observable.
17 *
18 * The function takes an interval as parameter, which indicates how often `now()` will return a new value.
19 * If no interval is given, it will update each second. If "frame" is specified, it will update each time a
20 * `requestAnimationFrame` is available.
21 *
22 * Multiple clocks with the same interval will automatically be synchronized.
23 *
24 * Countdown example: https://jsfiddle.net/mweststrate/na0qdmkw/
25 *
26 * @example
27 *
28 * const start = Date.now()
29 *
30 * autorun(() => {
31 * console.log("Seconds elapsed: ", (mobxUtils.now() - start) / 1000)
32 * })
33 *
34 *
35 * @export
36 * @param {(number | "frame")} [interval=1000] interval in milliseconds about how often the interval should update
37 * @returns
38 */
39export declare function now(interval?: number | "frame"): number;