Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Context<T>

An implementation of a document context. A namespace for Context statics.

This class is typically instantiated by the document manager.

Type parameters

Hierarchy

  • Context

Implements

Index

Constructors

constructor

Properties

Private _contentsModel

_contentsModel: IModel | null = null

Private _disposed

_disposed: Signal<this, void> = new Signal<this, void>(this)

Private _factory

_factory: IModelFactory<T>

Private _fileChanged

_fileChanged: Signal<this, IModel> = new Signal<this, Contents.IModel>(this)

Private _isDisposed

_isDisposed: boolean = false

Private _isPopulated

_isPopulated: boolean = false

Private _isReady

_isReady: boolean = false

Private _manager

_manager: IManager

Private _model

_model: T

Private _modelDB

_modelDB: IModelDB

Private _opener

_opener: function

Type declaration

Private _path

_path: string = ""

Private _pathChanged

_pathChanged: Signal<this, string> = new Signal<this, string>(this)

Private _populatedPromise

_populatedPromise: PromiseDelegate<void> = new PromiseDelegate<void>()

Private _readyPromise

_readyPromise: Promise<void>

Private _saveState

_saveState: Signal<this, "started" | "completed" | "failed"> = new Signal<this, DocumentRegistry.SaveState>(this)

Private _useCRLF

_useCRLF: boolean = false

session

session: ClientSession

The client session object associated with the context.

urlResolver

urlResolver: IResolver

The url resolver for the context.

Accessors

contentsModel

  • get contentsModel(): IModel | null
  • The current contents model associated with the document.

    Notes

    The contents model will be null until the context is populated. It will have an empty contents field.

    Returns IModel | null

disposed

  • get disposed(): ISignal<this, void>
  • A signal emitted when the context is disposed.

    Returns ISignal<this, void>

factoryName

  • get factoryName(): string
  • Get the model factory name.

    Notes

    This is not part of the IContext API.

    Returns string

fileChanged

  • get fileChanged(): ISignal<this, IModel>
  • A signal emitted when the model is saved or reverted.

    Returns ISignal<this, IModel>

isDisposed

  • get isDisposed(): boolean
  • Test whether the context is disposed.

    Returns boolean

isReady

  • get isReady(): boolean
  • Whether the context is ready.

    Returns boolean

localPath

  • get localPath(): string
  • The current local path associated with the document. If the document is in the default notebook file browser, this is the same as the path.

    Returns string

model

  • get model(): T
  • Get the model associated with the document.

    Returns T

path

  • get path(): string
  • The current path associated with the document.

    Returns string

pathChanged

  • get pathChanged(): ISignal<this, string>
  • A signal emitted when the path changes.

    Returns ISignal<this, string>

ready

  • get ready(): Promise<void>
  • A promise that is fulfilled when the context is ready.

    Returns Promise<void>

saveState

  • A signal emitted on the start and end of a saving operation.

    Returns ISignal<this, SaveState>

Methods

Private _finishSaveAs

  • _finishSaveAs(newPath: string): Promise<void>
  • Finish a saveAs operation given a new path.

    Parameters

    • newPath: string

    Returns Promise<void>

Private _handleError

  • _handleError(err: Error | ResponseError, title: string): Promise<void>
  • Handle a save/load error with a dialog.

    Parameters

    • err: Error | ResponseError
    • title: string

    Returns Promise<void>

Private _maybeCheckpoint

  • _maybeCheckpoint(force: boolean): Promise<void>
  • Add a checkpoint the file is writable.

    Parameters

    • force: boolean

    Returns Promise<void>

Private _maybeOverWrite

  • _maybeOverWrite(path: string): Promise<void>
  • Handle a time conflict.

    Parameters

    • path: string

    Returns Promise<void>

Private _maybeSave

  • _maybeSave(options: Partial<IModel>): Promise<IModel>
  • Save a file, dealing with conflicts.

    Parameters

    • options: Partial<IModel>

    Returns Promise<IModel>

Private _onFileChanged

  • _onFileChanged(sender: IManager, change: IChangedArgs): void
  • Handle a change on the contents manager.

    Parameters

    • sender: IManager
    • change: IChangedArgs

    Returns void

Private _onSessionChanged

  • _onSessionChanged(sender: IClientSession, type: string): void
  • Handle a change to a session property.

    Parameters

    • sender: IClientSession
    • type: string

    Returns void

Private _populate

  • _populate(): Promise<void>
  • Handle an initial population.

    Returns Promise<void>

Private _revert

  • _revert(initializeModel?: boolean): Promise<void>
  • Revert the document contents to disk contents.

    Parameters

    • Default value initializeModel: boolean = false

      call the model's initialization function after deserializing the content.

    Returns Promise<void>

Private _save

  • _save(): Promise<void>
  • Save the document contents to disk.

    Returns Promise<void>

Private _timeConflict

  • _timeConflict(tClient: Date, model: IModel, options: Partial<IModel>): Promise<IModel>
  • Handle a time conflict.

    Parameters

    • tClient: Date
    • model: IModel
    • options: Partial<IModel>

    Returns Promise<IModel>

Private _updateContentsModel

  • _updateContentsModel(model: IModel): void
  • Update our contents model, without the content.

    Parameters

    • model: IModel

    Returns void

addSibling

  • addSibling(widget: Widget, options?: IOpenOptions): IDisposable
  • Add a sibling widget to the document manager.

    Parameters

    • widget: Widget

      The widget to add to the document manager.

    • Default value options: IOpenOptions = {}

      The desired options for adding the sibling.

    Returns IDisposable

    A disposable used to remove the sibling if desired.

    Notes

    It is assumed that the widget has the same model and context as the original widget.

createCheckpoint

  • createCheckpoint(): Promise<ICheckpointModel>

deleteCheckpoint

  • deleteCheckpoint(checkpointId: string): Promise<void>

dispose

  • dispose(): void

initialize

  • initialize(isNew: boolean): Promise<void>
  • Initialize the context.

    Parameters

    • isNew: boolean

      Whether it is a new file.

    Returns Promise<void>

    a promise that resolves upon initialization.

listCheckpoints

  • listCheckpoints(): Promise<ICheckpointModel[]>

restoreCheckpoint

  • restoreCheckpoint(checkpointId?: string): Promise<void>

revert

  • revert(): Promise<void>

save

  • save(): Promise<void>

saveAs

  • saveAs(): Promise<void>
  • Save the document to a different path chosen by the user.

    Returns Promise<void>

Generated using TypeDoc