Home Reference Source
import {AppState} from './scripts/simple/app.js'
public class | source

AppState

Constructor Summary

Public Constructor
public

ctxClass is the context class.

Member Summary

Public Members
public

[k]: *

public

api: *

public

ctx: *

public
public
public get

fileExt: *

public set
public
public
public
public

screen: *

public
public
public
Private Members
private
private
private

Method Summary

Public Methods
public

Create a new file.

public
public

loadFile(data: ArrayBuffer | JSON | DataView, args: FileArgs): *

Loads a new file.

public
public

reset()

resets the undo stack

public

saveFile(objects: *, args: {}): *

Serialize the application state.

public

start(args: *): *

Public Constructors

public constructor() source

ctxClass is the context class. It can be either a simple class or a subclass of the more complex path.ux Context class. Note that using Context will avoid subtle undo stack errors caused by the context changing after a tool is run (this is why Context has a serialization mechanism).

Path.ux will actually subclass ctxClass and add a few standard methods and properties, see GetContextClass.

Public Members

public [k]: * source

public api: * source

public ctx: * source

public currentFileRef: * source

public defaultEditorClass: * source

public get fileExt: * source

public set fileExt source

public fileMagic: string source

public fileVersion: number[] source

public saveFilesInJSON: boolean source

public screen: * source

public screenClass: * source

public startArgs: * source

public toolstack: * source

Private Members

private _ctxClass: * source

private _fileExt: string source

private _fileExtSet: boolean source

Public Methods

public createNewFile() source

Create a new file. See this.makeScreen() if you wish to create a new screen at this time, and this.reset() if you wish to reset the undo stack

public ensureMenuBar() source

public loadFile(data: ArrayBuffer | JSON | DataView, args: FileArgs): * source

Loads a new file. The default behavior is a complete state reset (you can control this with args.reset_toolstack, args.reset_context and args.doScreen).

As the base class cannot know just what to do with the loaded data (the objects parameter passed to saveFile) it is recommended you override this function like so:

loadFile(data, args) { return super.loadFile(data, args).then(fileData) => { // load fileData.objects into appropriate properties // this is the same objects array originally passed // to this.saveFile this.data = fileData.objects; }); }

Params:

NameTypeAttributeDescription
data ArrayBuffer | JSON | DataView
args FileArgs

Return:

*

public makeScreen() source

public reset() source

resets the undo stack

public saveFile(objects: *, args: {}): * source

Serialize the application state. Takes a list of objects to save (with nstructjs); Subclasses should override this, like so:

saveFile(args={}) { let objects = app state; return super.saveFile(objects, args); }

Params:

NameTypeAttributeDescription
objects *
args {}
  • optional
  • default: {}

Return:

*

public start(args: *): * source

Params:

NameTypeAttributeDescription
args *
  • optional

Return:

*