Manager abstract base class

Hierarchy

  • ManagerBase

Implements

  • IWidgetManager

Constructors

Properties

_models: {
    [key: string]: Promise<WidgetModel>;
} = ...

Dictionary of model ids and model instance promises

Type declaration

  • [key: string]: Promise<WidgetModel>
comm_target_name: "jupyter.widget" = 'jupyter.widget'

The comm target name to register

Methods

  • Create a comm which can be used for communication for a widget.

    If the data/metadata is passed in, open the comm before returning (i.e., send the comm_open message). If the data and metadata is undefined, we want to reconstruct a comm that already exists in the kernel, so do not open the comm by sending the comm_open message.

    Parameters

    • comm_target_name: string

      Comm target name

    • Optional model_id: string

      The comm id

    • Optional data: JSONObject

      The initial data for the comm

    • Optional metadata: JSONObject

      The metadata in the open message

    • Optional buffers: ArrayBuffer[] | ArrayBufferView[]

    Returns Promise<IClassicComm>

  • Fetch all widgets states from the kernel using the control comm channel If this fails (control comm handler not implemented kernel side), it will fall back to _loadFromKernelModels.

    This is a utility function that can be used in subclasses.

    Returns Promise<void>

  • Old implementation of fetching widget models one by one using the request_state message on each comm.

    This is a utility function that can be used in subclasses.

    Returns Promise<void>

  • callback handlers specific to a view

    Parameters

    • Optional view: WidgetView

    Returns ICallbacks

  • Creates a promise for a view of a given model

    Notes

    The implementation must trigger the Lumino 'after-attach' and 'after-show' events when appropriate, which in turn will trigger the view's 'displayed' events.

    Make sure the view creation is not out of order with any state updates.

    Type Parameters

    • VT extends DOMWidgetView<VT> = DOMWidgetView

    Parameters

    • model: DOMWidgetModel
    • Optional options: any

    Returns Promise<VT>

  • Type Parameters

    • VT extends WidgetView<VT> = WidgetView

    Parameters

    • model: WidgetModel
    • Optional options: any

    Returns Promise<VT>

  • Filter serialized widget state to remove any ID's already present in manager.

    Returns

    A copy of the state, with its 'state' attribute filtered

    Parameters

    • serialized_state: any

    Returns any

  • Get a promise for a model by model id.

    Notes

    If the model is not found, the returned Promise object is rejected.

    If you would like to synchronously test if a model exists, use .has_model().

    Parameters

    • model_id: string

    Returns Promise<WidgetModel>

  • Handle when a comm is opened.

    Parameters

    • comm: IClassicComm
    • msg: ICommOpenMsg<"iopub" | "shell">

    Returns Promise<WidgetModel>

  • Returns true if the given model is registered, otherwise false.

    Notes

    This is a synchronous way to check if a model is registered.

    Parameters

    • model_id: string

    Returns boolean

  • Load a class and return a promise to the loaded object.

    Parameters

    • className: string
    • moduleName: string
    • moduleVersion: string

    Returns Promise<typeof WidgetModel | typeof WidgetView>

  • Parameters

    • className: string
    • moduleName: string
    • moduleVersion: string

    Returns Promise<typeof WidgetModel>

  • Parameters

    • className: string
    • moduleName: string
    • moduleVersion: string

    Returns Promise<typeof WidgetView>

  • Create and return a promise for a new widget model

    Example

    widget_manager.new_model({
    model_name: 'IntSlider',
    model_module: '@jupyter-widgets/controls',
    model_module_version: '1.0.0',
    model_id: 'u-u-i-d'
    }).then((model) => { console.log('Create success!', model); },
    (err) => {console.error(err)});

    Parameters

    • options: IModelOptions

      the options for creating the model.

    • serialized_state: any = {}

      attribute values for the model.

    Returns Promise<WidgetModel>

  • Create a comm and new widget model.

    Parameters

    • options: IWidgetOptions

      same options as new_model but comm is not required and additional options are available.

    • serialized_state: JSONObject = {}

      serialized model attributes.

    Returns Promise<WidgetModel>

  • Parameters

    • model_id: string
    • modelPromise: Promise<WidgetModel>

    Returns void

  • Resolve a URL relative to the current notebook location.

    The default implementation just returns the original url.

    Parameters

    • url: string

    Returns Promise<string>

  • Set the widget manager state.

    Parameters

    • state: IManagerState

      a Javascript object conforming to the application/vnd.jupyter.widget-state+json spec.

      Reconstructs all of the widget models in the state, merges that with the current manager state, and then attempts to redisplay the widgets in the state.

    Returns Promise<WidgetModel[]>

Generated using TypeDoc