Hierarchy

  • DOMWidgetModel
    • OutputModel

Constructors

  • Parameters

    • Optional attributes: any
    • Optional options: any

    Returns OutputModel

Properties

attributes: Partial<any>
changed: Partial<any>
cid: string
cidPrefix: string
collection: Collection<OutputModel>
comm?: IClassicComm
id: string | number
idAttribute: string
model_id: string
module: string
name: string
state_change: Promise<any>
url: (() => string)

Type declaration

    • (): string
    • Returns the relative URL where the model's resource would be located on the server.

      Returns string

urlRoot: _Result<string>
validationError: any
views?: {
    [key: string]: Promise<WidgetView>;
}

Type declaration

  • [key: string]: Promise<WidgetView>
widget_manager: IWidgetManager
serializers: ISerializers

Accessors

  • get comm_live(): boolean
  • Returns boolean

  • set comm_live(x: boolean): void
  • Parameters

    • x: boolean

    Returns void

Methods

  • Handle when a widget comm is closed.

    Parameters

    • msg: ICommCloseMsg<"iopub" | "shell">

    Returns void

  • Handle incoming comm msg.

    Parameters

    • msg: ICommMsgMsg<"iopub" | "shell">

    Returns Promise<void>

  • Handle status msgs.

    execution_state : ('busy', 'idle', 'starting')

    Parameters

    • msg: IStatusMsg

    Returns void

  • Parameters

    • eventName: string
    • callback: EventHandler
    • Optional context: any

    Returns OutputModel

  • Parameters

    • eventMap: EventMap
    • Optional context: any

    Returns OutputModel

  • Create msg callbacks for a comm msg.

    Parameters

    • Optional view: WidgetView

    Returns ICallbacks

  • Returns any

  • Return an object containing all the attributes that have changed, or false if there are no changed attributes. Useful for determining what parts of a view need to be updated and/or what attributes need to be persisted to the server. Unset attributes will be set to undefined. You can also pass an attributes object to diff against the model, determining if there would be a change.

    Parameters

    • Optional attributes: Partial<any>

    Returns false | Partial<any>

  • Parameters

    • Optional options: Silenceable

    Returns OutputModel

  • Returns Model<any, ModelSetOptions, any>

  • Close model

    Returns

    • a promise that is fulfilled when all the associated views have been removed.

    Parameters

    • Optional comm_closed: boolean

      true if the comm is already being closed. If false, the comm will be closed.

    Returns Promise<void>

  • Parameters

    • Optional options: ModelDestroyOptions

    Returns false | JQueryXHR

  • Parameters

    • attribute: string

    Returns string

  • Parameters

    • Optional options: ModelFetchOptions

    Returns JQueryXHR

  • For strongly-typed access to attributes, use the get method only privately in public getter properties.

    Example

    get name(): string {
    return super.get("name");
    }

    Type Parameters

    • A extends string

    Parameters

    • attributeName: A

    Returns any

  • Get the serializable state of the model.

    If drop_default is truthy, attributes that are equal to their default values are dropped.

    Parameters

    • Optional drop_defaults: boolean

    Returns JSONObject

  • Parameters

    • attribute: string

    Returns boolean

  • Parameters

    • Optional attribute: string

    Returns boolean

  • Constructor

    Initializes a WidgetModel instance. Called by the Backbone constructor.

    Parameters

    widget_manager : WidgetManager instance model_id : string An ID unique to this model. comm : Comm instance (optional)

    Parameters

    • attributes: ObjectHash
    • options: IBackboneModelOptions

    Returns void

  • Returns any

  • Returns boolean

  • Test to see if the model has been synced with the server.

    Notes

    As of backbone 1.1, backbone ignores patch if it thinks the model has never been pushed.

    Returns boolean

  • Parameters

    • Optional options: any

    Returns boolean

  • Returns string[]

  • Parameters

    • object: any
    • events: string
    • callback: EventHandler

    Returns OutputModel

  • Parameters

    • object: any
    • eventMap: EventMap

    Returns OutputModel

  • Parameters

    • object: any
    • events: string
    • callback: EventHandler

    Returns OutputModel

  • Parameters

    • object: any
    • eventMap: EventMap

    Returns OutputModel

  • Parameters

    • attrs: any

    Returns boolean

  • Parameters

    • Optional eventName: null | string
    • Optional callback: null | EventHandler
    • Optional context: any

    Returns OutputModel

  • Type Parameters

    • A extends string

    Parameters

    • keys: A[]

    Returns Partial<_Omit<any, A>>

  • Type Parameters

    • A extends string

    Parameters

    • Rest ...keys: A[]

    Returns Partial<_Omit<any, A>>

  • Parameters

    • fn: ((value: any, key: any, object: any) => any)
        • (value: any, key: any, object: any): any
        • Parameters

          • value: any
          • key: any
          • object: any

          Returns any

    Returns Partial<any>

  • Parameters

    • eventName: string
    • callback: EventHandler
    • Optional context: any

    Returns OutputModel

  • Parameters

    • eventMap: EventMap
    • Optional context: any

    Returns OutputModel

  • on_some_change(['key1', 'key2'], foo, context) differs from on('change:key1 change:key2', foo, context). If the widget attributes key1 and key2 are both modified, the second form will result in foo being called twice while the first will call foo only once.

    Parameters

    • keys: string[]
    • callback: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • context: any

    Returns void

  • Parameters

    • events: string
    • callback: EventHandler
    • Optional context: any

    Returns OutputModel

  • Parameters

    • eventMap: EventMap
    • Optional context: any

    Returns OutputModel

  • Returns any[]

  • Parameters

    • response: any
    • Optional options: any

    Returns any

  • Type Parameters

    • A extends string

    Parameters

    • keys: A[]

    Returns Partial<Pick<any, A>>

  • Type Parameters

    • A extends string

    Parameters

    • Rest ...keys: A[]

    Returns Partial<Pick<any, A>>

  • Parameters

    • fn: ((value: any, key: any, object: any) => any)
        • (value: any, key: any, object: any): any
        • Parameters

          • value: any
          • key: any
          • object: any

          Returns any

    Returns Partial<any>

  • For use with models as ES classes. If you define a preinitialize method, it will be invoked when the Model is first created, before any instantiation logic is run for the Model.

    See

    https://backbonejs.org/#Model-preinitialize

    Parameters

    • Optional attributes: any
    • Optional options: any

    Returns void

  • Type Parameters

    • A extends string

    Parameters

    • attribute: A

    Returns any

  • Returns Partial<any>

  • Parameters

    • msgId: string

    Returns void

  • Parameters

    • Optional attributes: null | Partial<any>
    • Optional options: ModelSaveOptions

    Returns JQueryXHR

  • Push this model's state to the back-end

    This invokes a Backbone.Sync.

    Parameters

    • Optional callbacks: {}

      Returns void

    • Send a custom msg over the comm.

      Parameters

      • content: JSONValue
      • Optional callbacks: ICallbacks
      • Optional buffers: ArrayBuffer[] | ArrayBufferView[]

      Returns void

    • Send a sync message to the kernel.

      If a message is sent successfully, this returns the message ID of that message. Otherwise it returns an empty string

      Parameters

      • state: JSONObject
      • Optional callbacks: any

      Returns string

    • Serialize widget state.

      A serializer is a function which takes in a state attribute and a widget, and synchronously returns a JSONable object. The returned object will have toJSON called if possible, and the final result should be a primitive object that is a snapshot of the widget state that may have binary array buffers.

      Parameters

      • state: Dict<any>

      Returns JSONObject

    • Set one or more values.

      We just call the super method, in which val and options are optional. Handles both "key", value and {key: value} -style arguments.

      Parameters

      • key: any
      • Optional val: any
      • Optional options: any

      Returns any

    • Handle when a widget is updated from the backend.

      This function is meant for internal use only. Values set here will not be propagated on a sync.

      Parameters

      • state: Dict<unknown>

      Returns void

    • Parameters

      • Optional object: any
      • Optional events: string
      • Optional callback: EventHandler

      Returns OutputModel

    • Handle sync to the back-end. Called when a model.save() is called.

      Make sure a comm exists.

      Parameters

      method : create, update, patch, delete, read create/update always send the full attribute set patch - only send attributes listed in options.attrs, and if we are queuing up messages, combine with previous messages that have not been sent yet model : the model we are syncing will normally be the same as this options : dict the attrs key, if it exists, gives an {attr: value} dict that should be synced, otherwise, sync all attributes.

      Parameters

      • method: string
      • model: WidgetModel
      • Optional options: any

      Returns any

    • Serialize the model. See the deserialization function at the top of this file and the kernel-side serializer/deserializer.

      Parameters

      • Optional options: {}

        Returns string

      • Parameters

        • eventName: string
        • Rest ...args: any[]

        Returns OutputModel

      • Parameters

        • Optional eventName: string
        • Optional callback: EventHandler
        • Optional context: any

        Returns OutputModel

      • Parameters

        • attribute: string
        • Optional options: Silenceable

        Returns OutputModel

      • Parameters

        • attributes: Partial<any>
        • Optional options: any

        Returns any

      • Returns any[]

      • Returns a promise for the deserialized state. The second argument is an instance of widget manager, which is required for the deserialization of widget models.

        Parameters

        • state: Dict<BufferJSON>
        • manager: IWidgetManager

        Returns Promise<Dict<unknown>>

      • Do not use, prefer TypeScript's extend functionality.

        Parameters

        • properties: any
        • Optional classProperties: any

        Returns any

      Generated using TypeDoc