Home Reference Source
import Application from '@osjs/client/src/application.js'
public class | source

Application

Extends:

@osjs/event-emitter~EventEmitter → Application

Base class for an Application

Static Method Summary

Static Public Methods
public static

Kills all running applications

public static

Get a list of all running applications

Constructor Summary

Public Constructor
public

constructor(core: Core, data: Object)

Create application

Member Summary

Public Members
public

args: Map<String, *>

Application arguments

public

Core instance reference

public

The application destruction state

public

Application metadata

public

Application options

public

The Application ID

public

Options for internal fetch/requests

public

Application settings

public

Application WebSockets

public

Application started time

public

Window list

public

workers: Worker[]

Worker instances

Method Summary

Public Methods
public

Create a new window belonging to this application

public

destroy(remove: boolean)

Destroy application

public

Emits an event across all (or filtered) applications

public

Gets a snapshot of the application session

public

Re-launch this application

public

Removes window(s) based on given filter

public

request(path: String, options: Options, type: String): Promise<*, Error>

Performs a request to the OS.js server with the application as the endpoint.

public

resource(path: String, options: Object): String

If given path is an URI it will just return itself.

public

Saves settings

public

send(args: ...*)

This does not create a new connection, but rather uses the core connection.

public

socket(path: String, options: Object): Websocket

Creates a new Websocket

public

worker(filename: String, options: Object): Worker

Creates a new Worker

Static Public Methods

public static destroyAll() source

Kills all running applications

public static getApplications(): Application[] source

Get a list of all running applications

Return:

Application[]

Public Constructors

public constructor(core: Core, data: Object) source

Create application

Params:

NameTypeAttributeDescription
core Core

Core reference

data Object

Application data

data.args Map<String, *>

Launch arguments

data.options Object
  • optional

Options

data.options.settings Object
  • optional

Initial settings

data.options.restore Object
  • optional

Restore data

data.options.windowAutoFocus Boolean
  • optional
  • default: true

Auto-focus first created window

data.options.sessionable Boolean
  • optional
  • default: true

Allow session storage

data.metadata PackageMetadata
  • optional

Package Metadata

Public Members

public args: Map<String, *> source

Application arguments

public core: Core source

Core instance reference

public destroyed: Boolean source

The application destruction state

public metadata: PackageMetadata source

Application metadata

public options: Object source

Application options

public pid: Number source

The Application ID

public requestOptions: Object source

Options for internal fetch/requests

public settings: Object source

Application settings

public sockets: Websocket[] source

Application WebSockets

public started: Date source

Application started time

public windows: Window[] source

Window list

public workers: Worker[] source

Worker instances

Public Methods

public createWindow(options: Object): Window source

Create a new window belonging to this application

Params:

NameTypeAttributeDescription
options Object

Window options

Return:

Window

See:

public destroy(remove: boolean) source

Destroy application

Params:

NameTypeAttributeDescription
remove boolean
  • optional
  • default: true

public emitAll(filter: Function): Function source

Emits an event across all (or filtered) applications

Params:

NameTypeAttributeDescription
filter Function
  • optional

A method to filter what applications to send to

Return:

Function

Function with 'emit()' signature

public getSession(): Object source

Gets a snapshot of the application session

Return:

Object

public relaunch() source

Re-launch this application

public removeWindow(filter: Function) source

Removes window(s) based on given filter

Params:

NameTypeAttributeDescription
filter Function

Filter function

public request(path: String, options: Options, type: String): Promise<*, Error> source

Performs a request to the OS.js server with the application as the endpoint.

Params:

NameTypeAttributeDescription
path String
  • optional
  • default: /

Append this to endpoint

options Options
  • optional

fetch options

type String
  • optional
  • default: 'json'

Request / Response type

Return:

Promise<*, Error>

ArrayBuffer or JSON

public resource(path: String, options: Object): String source

If given path is an URI it will just return itself.

Params:

NameTypeAttributeDescription
path String

The path

options Object
  • optional

Options for url() in core

Return:

String

A complete URI

public saveSettings(): Promise<Boolean, Error> source

Saves settings

Return:

Promise<Boolean, Error>

public send(args: ...*) source

This does not create a new connection, but rather uses the core connection. For subscribing to messages from the server use the 'ws:message' event

Params:

NameTypeAttributeDescription
args ...*

public socket(path: String, options: Object): Websocket source

Creates a new Websocket

Params:

NameTypeAttributeDescription
path String
  • optional
  • default: /socket

Append this to endpoint

options Object
  • optional

Connection options

Return:

Websocket

public worker(filename: String, options: Object): Worker source

Creates a new Worker

Params:

NameTypeAttributeDescription
filename String

Worker filename

options Object
  • optional

Worker options

Return:

Worker