Interface IWidgetTracker<T>

A tracker that tracks widgets.

Typeparam

T - The type of widget being tracked. Defaults to Widget.

interface IWidgetTracker<T> {
    currentChanged: ISignal<IWidgetTracker<T>, null | T>;
    currentWidget: null | T;
    isDisposed: boolean;
    restored: Promise<void>;
    size: number;
    widgetAdded: ISignal<IWidgetTracker<T>, T>;
    widgetUpdated: ISignal<IWidgetTracker<T>, T>;
    dispose(): void;
    filter(fn): T[];
    find(fn): undefined | T;
    forEach(fn): void;
    has(obj): boolean;
    inject(obj): void;
}

Type Parameters

Hierarchy

Implemented by

Properties

currentChanged: ISignal<IWidgetTracker<T>, null | T>

A signal emitted when the current instance changes.

Notes

If the last instance being tracked is disposed, null will be emitted.

currentWidget: null | T

The current widget is the most recently focused or added widget.

Notes

It is the most recently focused widget, or the most recently added widget if no widget has taken focus.

isDisposed: boolean

Test whether the object has been disposed.

Notes

This property is always safe to access.

restored: Promise<void>

A promise that is resolved when the widget tracker has been restored from a serialized state.

Notes

Most client code will not need to use this, since they can wait for the whole application to restore. However, if an extension wants to perform actions during the application restoration, but after the restoration of another widget tracker, they can use this promise.

size: number

The number of instances held by the tracker.

widgetAdded: ISignal<IWidgetTracker<T>, T>

A signal emitted when a widget is added.

widgetUpdated: ISignal<IWidgetTracker<T>, T>

A signal emitted when a widget is updated.

Methods

  • Dispose of the resources held by the object.

    Notes

    If the object's dispose method is called more than once, all calls made after the first will be a no-op.

    Undefined Behavior

    It is undefined behavior to use any functionality of the object after it has been disposed unless otherwise explicitly noted.

    Returns void

  • Filter the instances in the tracker based on a predicate.

    Parameters

    • fn: ((obj) => boolean)

      The function by which to filter.

        • (obj): boolean
        • Parameters

          • obj: T

          Returns boolean

    Returns T[]

  • Find the first instance in the tracker that satisfies a filter function.

    Parameters

    • fn: ((obj) => boolean)

      The filter function to call on each instance.

      Notes

      If nothing is found, the value returned is undefined.

        • (obj): boolean
        • Parameters

          • obj: T

          Returns boolean

    Returns undefined | T

  • Iterate through each instance in the tracker.

    Parameters

    • fn: ((obj) => void)

      The function to call on each instance.

        • (obj): void
        • Parameters

          • obj: T

          Returns void

    Returns void

  • Inject an instance into the widget tracker without the tracker handling its restoration lifecycle.

    Parameters

    • obj: T

      The instance to inject into the tracker.

    Returns void