Documentation

EventEmitter

Exposes methods that allow subscribing to particular events
EventEmitter is the base class for event emitting objects, such as Window.

ssf.Window.getCurrentWindow().on('focus', () => {
 console.log('Window received focus');
});

Methods

addListener

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Adds a listener that runs when the specified event occurs. Alias for on().

window.addListener('blur', () => {
  console.log('blurred');
});

Arguments
event [string]
The event to listen for.
listener [Function]
The function to run when the event occurs.
Returns
EventEmitter

eventNames

Get all event names with active listeners.

Returns
Array<string | symbol>

listenerCount

Get the number of listeners currently listening for an event.

Arguments
event [string]
The event to get the number of listeners for.
Returns
number

listeners

Get all listeners for an event.

Arguments
event [string]
The event to get the listeners for.
Returns
Array<Function>

on

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Adds a listener that runs when the specified event occurs. Alias for addListener().

window.on('blur', () => {
  console.log('blurred');
});

Arguments
event [string]
The event to listen for.
listener [Function]
The function to run when the event occurs.
Returns
EventEmitter

once

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Adds a listener that runs once when the specified event occurs, then is removed.

window.once('show', () => {
  console.log('shown');
});

Arguments
event [string]
The event to listen for.
listener [Function]
The function to run once when the event occurs.
Returns
EventEmitter

removeAllListeners

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Removes all listeners from a given event, or all events if no event is passed.

Arguments
event [string]
The event to remove the listeners from.
Returns
EventEmitter

removeListener

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Remove a listener from an event. Note: this must be the same function object.

const listener = () => {
  console.log('blurred');
};
window.addListener('blur', listener);

//...

window.removeListener('blur', listener);

Arguments
event [string]
The event to remove the listener from.
listener [Function]
The listener to remove. Must be the same object that was passed to addListener()
Returns
EventEmitter

MessageService

Send messages between windows
Messages can be sent between windows that are part of the same application. Subscribe to messages based on a topic name, and either send messages from or to a particular window id, or else distribute to all listening windows. Messages are sent asynchronously.

// Listen for messages from any window with the subject "test-subject"
ssf.MessageService.subscribe('*', 'test-subject', (message, sender) => {
  console.log(`${message} from ${sender}`);
});

// Send a message to all windows listening to "test-subject"
ssf.MessageService.send('*', 'test-subject', 'This is a test message');

Static Methods

send

Tests
15/15
Electron
5/5
OpenFin
5/5
Browser
5/5

Send a message to a specific window

Arguments
windowId [string]
The id of the window to send the message to. Can be a wildcard '*' to send to all listening windows.
topic [string]
The topic of the message.
message [string | any]
The message to send.
Returns
void

subscribe

Tests
12/12
Electron
4/4
OpenFin
4/4
Browser
4/4

Subscribe to message from a window/topic

Arguments
windowId [string]
The id of the window to listen to messages from. Can be a wildcard '*' to listen to all windows.
topic [string]
The topic to listen for.
listener [(message: string | any,sender: string) => void]
The function to run when a message is received. The message and sender window id are passed as a parameter to the function.
Returns
void

unsubscribe

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Unsubscribe from a window/topic

Arguments
windowId [string]
The id of the window that the listener was subscribed to or the wildcard '*'.
topic [string]
The topic that was being listened to.
listener [(message: string | any,sender: string) => void]
The function that was passed to subscribe. Note: this must be the same function object.
Returns
void

Notification

Creates a new Desktop Notification.
Notifications are created via a constructor which takes a title and an options object with body text and additional view options.
A Notification emits click events when the user clicks on it

ssf.Notification.requestPermission().then(result => {
  if (result === 'granted') {
    const notification = new Notification(
      'My Title',
      {
        body: 'My body text'
      });

    notification.on('click', () => {
      // Respond to click event
      console.log('Notification was clicked');
    });
  }
})
OpenFin requires a template html file to render the notification. A template (notification.html) is included with the containerjs bundle, and by default ssf.Notification will try to find it in the same location as the current URL. To specify a different URL for the template, set the template setting in NotificationOptions
const notification = new ssf.Notification(
  'My Title',
  {
    body: 'My body text',
    template: '/resource/notification.html'
  });
Notification is an EventEmitter. See NotificationEvent for a list of events.

Static Methods

requestPermission

Request permission to create notifications
If required, ask the user for permission to create desktop notifications. Some containers don't require permission so will resolve the promise immediately with the result "granted"

Returns
Promise<NotificationPermission>
A promise which resolves to a string value "granted" or "denied".

Constructors

new Notification

Create a notification

Arguments
title [string]
The title text of the notification.
options [NotificationOptions]
The notification options.
Returns
Notification

Methods

addListener

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Adds a listener that runs when the specified event occurs. Alias for on().

window.addListener('blur', () => {
  console.log('blurred');
});

Arguments
event [string]
The event to listen for.
listener [Function]
The function to run when the event occurs.
Returns
EventEmitter

eventNames

Get all event names with active listeners.

Returns
Array<string | symbol>

listenerCount

Get the number of listeners currently listening for an event.

Arguments
event [string]
The event to get the number of listeners for.
Returns
number

listeners

Get all listeners for an event.

Arguments
event [string]
The event to get the listeners for.
Returns
Array<Function>

on

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Adds a listener that runs when the specified event occurs. Alias for addListener().

window.on('blur', () => {
  console.log('blurred');
});

Arguments
event [string]
The event to listen for.
listener [Function]
The function to run when the event occurs.
Returns
EventEmitter

once

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Adds a listener that runs once when the specified event occurs, then is removed.

window.once('show', () => {
  console.log('shown');
});

Arguments
event [string]
The event to listen for.
listener [Function]
The function to run once when the event occurs.
Returns
EventEmitter

removeAllListeners

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Removes all listeners from a given event, or all events if no event is passed.

Arguments
event [string]
The event to remove the listeners from.
Returns
EventEmitter

removeListener

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Remove a listener from an event. Note: this must be the same function object.

const listener = () => {
  console.log('blurred');
};
window.addListener('blur', listener);

//...

window.removeListener('blur', listener);

Arguments
event [string]
The event to remove the listener from.
listener [Function]
The listener to remove. Must be the same object that was passed to addListener()
Returns
EventEmitter

Screen

Exposes methods that relate to the Screen and Display Monitors.

ssf.Screen.getDisplays().then(displays => {
  console.log(`${displays.length} displays`);
});

Static Methods

getDisplays

Get all the monitor displays that are available.
Note that the Browser API does not support multiple displays, so it assumes the display the browser is running in is the only display.

Returns
Promise<Array<Display>>
A promise which resolves to an array of available displays.

Window

Creates and controls windows.
The full Window interface is only available in OpenFin and Electron. For Browser and features available in all platforms, use WindowCore instead.
Windows are created via a constructor which takes a configuration object that details the window's behaviour.

const win = new Window({
  url: 'http://localhost/index.html'
});
Window is an EventEmitter. See WindowEvent for a list of events.

Static Methods

getAll

Tests
2/2
Electron
1/1
OpenFin
1/1

Returns all of the current windows.

Returns
Promise<Array<Window>>

getById

Tests
4/4
Electron
2/2
OpenFin
2/2

Get the window object with a particular id. Returns null if no window with that id exists.

Arguments
id [string]
The id of the window.
Returns
Promise<Window>

getCurrentWindow

Gets the current window object.

// Close the current window
ssf.Window.getCurrentWindow().close();

Arguments
callback [() => void]
Function that is called when the window is ready to be used (if newly created).
errorCallback [() => void]
Function that is called when the window wrapper could not be created.
Returns
Window
The window.

wrap

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Wraps a native container window with a ContainerJS window.

Arguments
window [BrowserWindow | OpenFinWindow | BrowserWindow]
The native window to wrap.
Returns
Window

Constructors

new Window

Create a new window.

Arguments
opts [WindowOptions]
A window options object
callback [(window: Window) => void]
A callback that is called if the window creation succeeds
errorCallback [() => void]
A callback that is called if window creation fails
Returns
Window
The window.

Properties

id

The id that uniquely identifies the window

innerWindow

The native window for the platform the API is running on.

Methods

addListener

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Adds a listener that runs when the specified event occurs. Alias for on().

window.addListener('blur', () => {
  console.log('blurred');
});

Arguments
event [string]
The event to listen for.
listener [Function]
The function to run when the event occurs.
Returns
EventEmitter

blur

Tests
2/2
Electron
1/1
OpenFin
1/1

Removes focus from the window.

Returns
Promise<void>

capture

Captures the current visible content for the given Window. Returns the image as a base64 encoded png string.
Note: For the browser, this is limited by the usual cross-domain rules.

childWindow.capture().then(base64Png => {
 document.querySelector('.screenshot').style.background
     = `url(data:image/png;base64,${base64Png}`);
});

Returns
Promise<string>
A promise that resolves to a base64 encoded png

close

Tests
9/9
Electron
3/3
OpenFin
3/3
Browser
3/3

Closes the window. Only works on windows created via the ContainerJS API in the browser.

Returns
Promise<void>
A promise which resolves to nothing when the function has completed.

eventNames

Get all event names with active listeners.

Returns
Array<string | symbol>

flashFrame

Tests
0/0
Electron
0/0
OpenFin
0/0

Flashes the window's frame and taskbar icon.

Arguments
flag [boolean]
Flag to start or stop the window flashing.
Returns
Promise<void>
A promise which resolves to nothing when the function has completed.

focus

Tests
0/0
Electron
0/0
OpenFin
0/0

Focuses the window.

Returns
Promise<void>
A promise which resolves to nothing when the function has completed.

getBounds

Tests
2/2
Electron
1/1
OpenFin
1/1

Returns the bounds of the window.

window.getBounds().then(bounds => {
  console.log(`window is ${bounds.width}px wide and ${bounds.height}px high`);
});

Returns
Promise<Rectangle>
A promise that resolves to an object specifying the bounds of the window.

getChildWindows

Tests
9/9
Electron
3/3
OpenFin
3/3
Browser
3/3

Get the child windows of the window.

// Close all child windows
window.getChildWindows().then(children => {
  children.forEach(child => {
    child.close();
  });
});

Returns
Promise<ReadonlyArray<Window>>
A promise that resolves to an array of child windows.

getId

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Gets the id of the window.

// Send the child window a message
const childId = childWindow.getId();
ssf.MessageService.send(childId, 'greetings', 'Hello child window');

Returns
string
The window id.

getMaximumSize

Tests
4/4
Electron
2/2
OpenFin
2/2

Get the maximum size of the window.

Returns
Promise<ReadonlyArray<number>>
A promise that resolves to an array containing the maximum width and height of the window.

getMinimumSize

Tests
4/4
Electron
2/2
OpenFin
2/2

Get the minimum size of the window.

Returns
Promise<ReadonlyArray<number>>
A promise that resolves to an array containing the minimum width and height of the window.

getParentWindow

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Get the parent of the window. Null will be returned if the window has no parent.

// Send the parent window a message
window.getParentWindow().then(parent => {
  const parentId = parent.getId();
  ssf.MessageService.send(parentId, 'greetings', 'Hello parent window');
});

Returns
Promise<Window | WindowCore>
The parent window.

getPosition

Tests
6/6
Electron
2/2
OpenFin
2/2
Browser
2/2

Get the position of the window.

Returns
Promise<ReadonlyArray<number>>
A promise that resolves to an array of integers containing the x and y coordinates of the window.

getSize

Tests
4/4
Electron
2/2
OpenFin
2/2

Get the width and height of the window.

Returns
Promise<ReadonlyArray<number>>
A promise that resolves to an array of integers containing the width and height of the window.

getTitle

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Get the title of the window

Returns
Promise<string>
The title of the window.

hasShadow

Tests
2/2
Electron
1/1
OpenFin
1/1

Check if the window has a shadow.

Returns
Promise<boolean>
A promise that resolves to a boolean stating if the window has a shadow.

hide

Tests
0/0
Electron
0/0
OpenFin
0/0

Hides the window.

Returns
Promise<void>
A promise that resolves to nothing when the window has hidden.

isAlwaysOnTop

Tests
2/2
Electron
1/1
OpenFin
1/1

Check if the window is always on top of all other windows.

Returns
Promise<boolean>
A promise that resolves to a boolean stating if the window is always on top.

isMaximizable

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Check if the window can be maximized.

Returns
Promise<boolean>
A promise that resolves to a boolean stating if the window can be maximized.

isMaximized

Tests
2/2
Electron
1/1
OpenFin
1/1

Check if the window is currently maximized.

Returns
Promise<boolean>
A promise that resolves to a boolean stating if the window is maximized.

isMinimizable

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Check if the window can be minimized.

Returns
Promise<boolean>
A promise that resolves to a boolean stating if the window can be minimized.

isMinimized

Tests
2/2
Electron
1/1
OpenFin
1/1

Check if the window is currently minimized.

Returns
Promise<boolean>
A promise that resolves to a boolean stating if the window is minimized.

isResizable

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Check if the window can be resized.

Returns
Promise<boolean>
A promise that resolves to a boolean stating if the window can be resized.

isVisible

Tests
2/2
Electron
1/1
OpenFin
1/1

Check is the window is currently visible

Returns
Promise<boolean>
A promise that resolves to a boolean stating if the window is visible

listenerCount

Get the number of listeners currently listening for an event.

Arguments
event [string]
The event to get the number of listeners for.
Returns
number

listeners

Get all listeners for an event.

Arguments
event [string]
The event to get the listeners for.
Returns
Array<Function>

loadURL

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Load a new URL in the window.

window.loadUrl('show-results.html');

Arguments
url [string]
The URL to load in the window.
Returns
Promise<void>
A promise that resolves when the window method succeeds.

maximize

Tests
2/2
Electron
1/1
OpenFin
1/1

Maximize the window.

Returns
Promise<void>
A promise that resolves to nothing when the window has maximized.

minimize

Tests
2/2
Electron
1/1
OpenFin
1/1

Minimize the window.

Returns
Promise<void>
A promise that resolves to nothing when the window has minimized.

on

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Adds a listener that runs when the specified event occurs. Alias for addListener().

window.on('blur', () => {
  console.log('blurred');
});

Arguments
event [string]
The event to listen for.
listener [Function]
The function to run when the event occurs.
Returns
EventEmitter

once

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Adds a listener that runs once when the specified event occurs, then is removed.

window.once('show', () => {
  console.log('shown');
});

Arguments
event [string]
The event to listen for.
listener [Function]
The function to run once when the event occurs.
Returns
EventEmitter

postMessage

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Send a message to the window.
The recipient window will get a `message` WindowEvent

Arguments
message [string | Object]
The message to send to the window. Can be any serializable object.
Returns
void

reload

Tests
0/0
Electron
0/0
OpenFin
0/0

Reload the window.

Returns
Promise<void>
A promise that resolves when the window method succeeds.

removeAllListeners

Tests
6/6
Electron
2/2
OpenFin
2/2
Browser
2/2

Removes all listeners from a given event, or all events if no event is passed.

Arguments
event [string]
The event to remove the listeners from.
Returns
EventEmitter

removeListener

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Remove a listener from an event. Note: this must be the same function object.

const listener = () => {
  console.log('blurred');
};
window.addListener('blur', listener);

//...

window.removeListener('blur', listener);

Arguments
event [string]
The event to remove the listener from.
listener [Function]
The listener to remove. Must be the same object that was passed to addListener()
Returns
EventEmitter

restore

Tests
4/4
Electron
2/2
OpenFin
2/2

Restores the window to the previous state.

Returns
Promise<void>
A promise that resolves to nothing when the window method succeeds.

setAlwaysOnTop

Tests
2/2
Electron
1/1
OpenFin
1/1

Sets the window to always be on top of other windows.

Arguments
alwaysOnTop [boolean]
Sets if the window is always on top.
Returns
Promise<void>
A promise that resolves to nothing when the option is set.

setBounds

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Sets the window to always be on top of other windows.

Arguments
bounds [Rectangle]
Sets the bounds of the window.
Returns
Promise<void>
A promise that resolves to nothing when the option is set.

setIcon

Tests
2/2
Electron
1/1
OpenFin
1/1

Sets the window icon.

Arguments
icon [string]
The url to the image.
Returns
Promise<void>
A promise that resolves to nothing when the option has been set.

setMaximizable

Tests
2/2
Electron
1/1
OpenFin
1/1

Sets if the window can be maximized.

Arguments
maximizable [boolean]
Set if the window can be maximized.
Returns
Promise<void>
A promise that resolves to nothing when the option has been set.

setMaximumSize

Tests
4/4
Electron
2/2
OpenFin
2/2

Sets the windows maximum size.

Arguments
maxWidth [number]
The maximum width of the window.
maxHeight [number]
The maximum height of the window.
Returns
Promise<void>
A promise that resolves to nothing when the option has been set.

setMinimizable

Tests
2/2
Electron
1/1
OpenFin
1/1

Sets if the window can be minimized.

Arguments
minimizable [boolean]
Set if the window can be minimized.
Returns
Promise<void>
A promise that resolves to nothing when the option has been set.

setMinimumSize

Tests
4/4
Electron
2/2
OpenFin
2/2

Sets the windows minimum size.

Arguments
minWidth [number]
The minimum width of the window.
minHeight [number]
The minimum height of the window.
Returns
Promise<void>
A promise that resolves to nothing when the option has been set.

setPosition

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Sets the windows position.

Arguments
x [number]
The x position of the window.
y [number]
The y position of the window.
Returns
Promise<void>
A promise that resolves to nothing when the option has been set.

setResizable

Tests
2/2
Electron
1/1
OpenFin
1/1

Sets if the window is resizable.

Arguments
resizable [boolean]
If the window can be resized.
Returns
Promise<void>
A promise that resolves to nothing when the option has been set.

setSize

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Sets the width and height of the window.

Arguments
width [number]
The width of the window.
height [number]
The height of the window.
Returns
Promise<void>
A promise that resolves to nothing when the option has been set.

setSkipTaskbar

Tests
0/0
Electron
0/0
OpenFin
0/0

Sets if the window is shown in the taskbar.

Arguments
skipTaskbar [boolean]
If the window is shown in the taskbar.
Returns
Promise<void>
A promise that resolves to nothing when the option has been set.

show

Tests
0/0
Electron
0/0
OpenFin
0/0

Show the window.

Returns
Promise<void>
A promise that resolves to nothing when the window is showing.

unmaximize

Tests
2/2
Electron
1/1
OpenFin
1/1

Unmaximize the window.

Returns
Promise<void>
A promise that resolves to nothing when the window has unmaximized.

WindowCore

Creates and controls windows.
WindowCore is implemented in the Browser, which offers a subset of the features available in OpenFin and Electron. For OpenFin and Electron specific behaviour, see Window instead.
Windows are created via a constructor which takes a configuration object that details the window's behaviour.

const win = new Window({
  url: 'http://localhost/index.html'
});
WindowCore is an EventEmitter. See WindowEvent for a list of events.

Static Methods

getCurrentWindow

Gets the current window object.

// Close the current window
ssf.Window.getCurrentWindow().close();

Arguments
callback [() => void]
Function that is called when the window is ready to be used (if newly created).
errorCallback [() => void]
Function that is called when the window wrapper could not be created.
Returns
Window
The window.

wrap

Wraps a native container window with a ContainerJS window.

Arguments
window [BrowserWindow | OpenFinWindow | BrowserWindow]
The native window to wrap.
Returns
Window

Constructors

new WindowCore

Create a new window.

Arguments
opts [WindowOptions]
A window options object
callback [(window: Window) => void]
A callback that is called if the window creation succeeds
errorCallback [() => void]
A callback that is called if window creation fails
Returns
WindowCore
The window.

Properties

id

The id that uniquely identifies the window

innerWindow

The native window for the platform the API is running on.

Methods

addListener

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Adds a listener that runs when the specified event occurs. Alias for on().

window.addListener('blur', () => {
  console.log('blurred');
});

Arguments
event [string]
The event to listen for.
listener [Function]
The function to run when the event occurs.
Returns
EventEmitter

blur

Removes focus from the window.

Returns
Promise<void>

capture

Tests
6/6
Electron
2/2
OpenFin
2/2
Browser
2/2

Captures the current visible content for the given Window. Returns the image as a base64 encoded png string.
Note: For the browser, this is limited by the usual cross-domain rules.

childWindow.capture().then(base64Png => {
 document.querySelector('.screenshot').style.background
     = `url(data:image/png;base64,${base64Png}`);
});

Returns
Promise<string>
A promise that resolves to a base64 encoded png

close

Tests
9/9
Electron
3/3
OpenFin
3/3
Browser
3/3

Closes the window. Only works on windows created via the ContainerJS API in the browser.

Returns
Promise<void>
A promise which resolves to nothing when the function has completed.

eventNames

Get all event names with active listeners.

Returns
Array<string | symbol>

focus

Focuses the window.

Returns
Promise<void>
A promise which resolves to nothing when the function has completed.

getBounds

Returns the bounds of the window.

window.getBounds().then(bounds => {
  console.log(`window is ${bounds.width}px wide and ${bounds.height}px high`);
});

Returns
Promise<Rectangle>
A promise that resolves to an object specifying the bounds of the window.

getChildWindows

Tests
9/9
Electron
3/3
OpenFin
3/3
Browser
3/3

Get the child windows of the window.

// Close all child windows
window.getChildWindows().then(children => {
  children.forEach(child => {
    child.close();
  });
});

Returns
Promise<ReadonlyArray<Window>>
A promise that resolves to an array of child windows.

getId

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Gets the id of the window.

// Send the child window a message
const childId = childWindow.getId();
ssf.MessageService.send(childId, 'greetings', 'Hello child window');

Returns
string
The window id.

getParentWindow

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Get the parent of the window. Null will be returned if the window has no parent.

// Send the parent window a message
window.getParentWindow().then(parent => {
  const parentId = parent.getId();
  ssf.MessageService.send(parentId, 'greetings', 'Hello parent window');
});

Returns
Promise<Window | WindowCore>
The parent window.

getPosition

Tests
6/6
Electron
2/2
OpenFin
2/2
Browser
2/2

Get the position of the window.

Returns
Promise<ReadonlyArray<number>>
A promise that resolves to an array of integers containing the x and y coordinates of the window.

getSize

Get the width and height of the window.

Returns
Promise<ReadonlyArray<number>>
A promise that resolves to an array of integers containing the width and height of the window.

getTitle

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Get the title of the window

Returns
Promise<string>
The title of the window.

isMaximizable

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Check if the window can be maximized.

Returns
Promise<boolean>
A promise that resolves to a boolean stating if the window can be maximized.

isMinimizable

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Check if the window can be minimized.

Returns
Promise<boolean>
A promise that resolves to a boolean stating if the window can be minimized.

isResizable

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Check if the window can be resized.

Returns
Promise<boolean>
A promise that resolves to a boolean stating if the window can be resized.

listenerCount

Get the number of listeners currently listening for an event.

Arguments
event [string]
The event to get the number of listeners for.
Returns
number

listeners

Get all listeners for an event.

Arguments
event [string]
The event to get the listeners for.
Returns
Array<Function>

loadURL

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Load a new URL in the window.

window.loadUrl('show-results.html');

Arguments
url [string]
The URL to load in the window.
Returns
Promise<void>
A promise that resolves when the window method succeeds.

on

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Adds a listener that runs when the specified event occurs. Alias for addListener().

window.on('blur', () => {
  console.log('blurred');
});

Arguments
event [string]
The event to listen for.
listener [Function]
The function to run when the event occurs.
Returns
EventEmitter

once

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Adds a listener that runs once when the specified event occurs, then is removed.

window.once('show', () => {
  console.log('shown');
});

Arguments
event [string]
The event to listen for.
listener [Function]
The function to run once when the event occurs.
Returns
EventEmitter

postMessage

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Send a message to the window.
The recipient window will get a `message` WindowEvent

Arguments
message [string | Object]
The message to send to the window. Can be any serializable object.
Returns
void

reload

Reload the window.

Returns
Promise<void>
A promise that resolves when the window method succeeds.

removeAllListeners

Tests
6/6
Electron
2/2
OpenFin
2/2
Browser
2/2

Removes all listeners from a given event, or all events if no event is passed.

Arguments
event [string]
The event to remove the listeners from.
Returns
EventEmitter

removeListener

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Remove a listener from an event. Note: this must be the same function object.

const listener = () => {
  console.log('blurred');
};
window.addListener('blur', listener);

//...

window.removeListener('blur', listener);

Arguments
event [string]
The event to remove the listener from.
listener [Function]
The listener to remove. Must be the same object that was passed to addListener()
Returns
EventEmitter

setBounds

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Sets the window to always be on top of other windows. Only works on windows created via the ContainerJS API in the browser.

Arguments
bounds [Rectangle]
Sets the bounds of the window.
Returns
Promise<void>
A promise that resolves to nothing when the option is set.

setPosition

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Sets the windows position. Only works on windows created via the ContainerJS API in the browser.

Arguments
x [number]
The x position of the window.
y [number]
The y position of the window.
Returns
Promise<void>
A promise that resolves to nothing when the option has been set.

setSize

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Sets the width and height of the window. Only works on windows created via the ContainerJS API in the browser.

Arguments
width [number]
The width of the window.
height [number]
The height of the window.
Returns
Promise<void>
A promise that resolves to nothing when the option has been set.

app

Manage the ContainerJS application

Static Methods

ready

Wait until the API has bootstrapped before it is ready to use
Note that some APIs may fail if the application tries to call them before the API layer has finished bootstrapping.

ssf.app.ready().then(() => {
 console.log('Application is running');
});

Returns
Promise<any>
A promise that resolves when the API has finished bootstrapping.

setBadgeCount

Sets the counter badge for current app. Setting the count to 0 will hide the badge. This is currently only supported in Electron on Mac and Linux.

Arguments
count [number]
the integer count for the app.
Returns
any

Display

Information about the user's display. Note that the Browser API does not support multiple displays, so it assumes the display the browser is running in is the only display.
The Screen class can be used to retrieve display information.

Properties

bounds

Bounds of the display.

id

Unique Id of the display.

primary

If the display is the primary display

rotation

Current rotation of the display, can be 0, 90, 180, 270.

scaleFactor

How much the display has been scaled.

NotificationOptions

Options that can be passed to the notification constructor

Properties

body

The text to display underneath the title text.

icon

The URL of an icon to be displayed in the notification.

image

The URL of an image to be displayed in the notification.

template

The URL of the notification template for OpenFin. Can be relative to the current URL. Default: "template.html"

Position

Position of an object on screen

Properties

x

Horizontal position in pixels

y

Vertical position in pixels

Rectangle

Position and size of an object on screen

Properties

height

Height in pixels

width

Width in pixels

x

Horizontal position in pixels

y

Vertical position in pixels

WindowOptions

Options that can be passed to the window constructor

Properties

alwaysOnTop

Whether the window should always stay on top of other windows. Default is false.

backgroundColor

Window’s background color as Hexadecimal value.

center

Tests
2/2
Electron
1/1
OpenFin
1/1

Show window in the center of the screen.

child

Whether the window is a child of the current window. Default is false.

display

The id of the display to show the window on. If no id is passed in, the x and y position of the window is relative to the primary monitor.

frame

If false, creates a frameless window. Default is true.

hasShadow

Whether window should have a shadow. This is only implemented on macOS. Default is true.

height

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Window’s height in pixels.

maxHeight

Tests
2/2
Electron
1/1
OpenFin
1/1

Window’s maximum height.

maxWidth

Window’s maximum width.

maximizable

Whether window is maximizable. Default is true.

minHeight

Tests
2/2
Electron
1/1
OpenFin
1/1

Window’s minimum height.

minWidth

Window’s minimum width.

minimizable

Whether window is minimizable. Default is true.

name

Default window title.

resizable

Whether window is resizable. Default is true.

show

Whether window should be shown when created. Default is true.

skipTaskbar

Whether to show the window in taskbar. Default is false.

transparent

Makes the window transparent. Default is false.

url

URL that this window loads.

width

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Window’s width in pixels.

x

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Window’s left offset from screen.

y

Tests
3/3
Electron
1/1
OpenFin
1/1
Browser
1/1

Window’s top offset from screen.

NotificationEvent

Events that are fired by Notification

Events

click

Fires when the notification is clicked

WindowEvent

Events that are fired by Window or WindowCore

Events

blur

Tests
2/2
Electron
1/1
OpenFin
1/1

Fires when the window has been blurred

capture

Fires when a screenshot of the window has been captured

close

Fires when the window is about to close

closed

Tests
0/0
Electron
0/0
OpenFin
0/0

Fires when the window has closed

focus

Tests
2/2
Electron
1/1
OpenFin
1/1

Fires when the window has been focused

hide

Tests
2/2
Electron
1/1
OpenFin
1/1

Fires when the window has been hidden

maximize

Tests
2/2
Electron
1/1
OpenFin
1/1

Fires when the window has been maximized (not implemented in Browser)

message

Fires when the window has received a message from PostMessage

minimize

Tests
2/2
Electron
1/1
OpenFin
1/1

Fires when the window has been minimized (not implemented in Browser)

move

Tests
2/2
Electron
1/1
OpenFin
1/1

Fires when the window has been moved (not implemented in Browser)

resize

Tests
2/2
Electron
1/1
OpenFin
1/1

Fires when the window has been resized

restore

Tests
2/2
Electron
1/1
OpenFin
1/1

Fires when the window has been restored (not implemented in Browser)

show

Tests
2/2
Electron
1/1
OpenFin
1/1

Fires when the window has been shown