Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • NestedStart

Callable

  • Starts a timing tree. Unlike the normal start method, this method does not return a stop function. Instead, it returns an array. The first value in the array is the stop function; the second argument is another start function you can invoke to begin a new nested timing.

    example
    import { tracker } from '~/tracking';
    import { someDataCall, someOtherDataCall } from '~/data/operations';

    const child = tracker.child();
    const logger = trackers.utils.withNesting(child);

    export async function loadData(id) {
    try {
    const [stop, start] = logger.start('load data');
    const data = await someDataCall(id);
    const results = await loadNestedData(start, data);
    stop({ id, results });
    return results;
    } catch (e) {
    logger.error(e);
    }
    }

    async function loadNestedData(start, data) {
    const [stop, ] = start('load nested data');
    const results = await someOtherDataCall(data);
    stop();
    return results;
    }

    Parameters

    • label: string

      The label of the nested timer to create.

    Returns NestedStartResult

    The [stop, start] methods you can use to end the current timing or start a nested timing. The first function is a normal TimerStopFunction and the second function is another NestedTimingTracker.start function.