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
this method was deprecated.

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

this method was deprecated.

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