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

Create application

Member Summary

Public Members
public

args: {foo: *}

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

settings: {foo: *}

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<*>

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

public

resource(path: string, options: object): string

Gets a URI to a resource for this application

public

Saves settings

public

send()

Sends a message over websocket via the core connection.

public

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: ApplicationData) source

Create application

Params:

NameTypeAttributeDescription
core Core

Core reference

data ApplicationData

Application data

Public Members

public args: {foo: *} 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: ApplicationOptions source

Application options

public pid: Number source

The Application ID

public requestOptions: object source

Options for internal fetch/requests

public settings: {foo: *} 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: WindowOptions): Window source

Create a new window belonging to this application

Params:

NameTypeAttributeDescription
options WindowOptions
  • optional
  • default: {}

Window options

Return:

Window

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(): ApplicationSession source

Gets a snapshot of the application session

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<*> 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<*>

ArrayBuffer or JSON

public resource(path: string, options: object): string source

Gets a URI to a resource for this application

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> source

Saves settings

Return:

Promise<boolean>

public send() source

Sends a message over websocket via the core connection.

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 *

Arguments to pass to message

public socket(path: string, options: WebsocketOptions): Websocket source

Creates a new Websocket

Params:

NameTypeAttributeDescription
path string
  • optional
  • default: /socket

Append this to endpoint

options WebsocketOptions
  • optional
  • default: {}

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