node package manager

seer

Seer API

This library provides an abstraction around the Window.postMessage API to interact with the Seer extension.

How the communication is done exactly relies on the bridge, that you can checkout in its dedicated directory. The following schema represent the complete data flow:

Install

Simply download the package from the npm registry

yarn add seer

Notes

The extension will declare a __SEER_INITIALIZED__ boolean on the window, that you can use to check if the extension is installed and prevent any useless processing in production or for real-users.

Functions

send(type, payload)

Low-level api leveraging window.postMessage

init()

Initilize window listener. There will be only one for the whole process to prevent too many registrations.

This method will be called automatically if you use the listenFor method.

clean()

Clean listener. Can be useful in case you want to unregister upcoming events or liberate memory.

listenFor(key, cb)

Create a listener that will be called upon events of the given key

createTab(key)

Basic tab creation

removeTab(key)

Basic tab deletion

list(key, data)

Creates a new simple list TODO push, remove

indexedList(key, data)

Creates a new indexed list, usefull for O(1) accessing and performance

indexedListItem(key, itemKey, data)

Creates/Update an element in the indexed list, based on the itemKey

send(type, payload)

Low-level api leveraging window.postMessage

Kind: global function

Param Type Description
type String The action type
payload Any The action payload

init()

Initilize window listener. There will be only one for the whole process to prevent too many registrations.

This method will be called automatically if you use the listenFor method.

Kind: global function

clean()

Clean listener. Can be useful in case you want to unregister upcoming events or liberate memory.

Kind: global function

listenFor(key, cb)

Create a listener that will be called upon events of the given key

Kind: global function

Param Type Description
key String The unique tab key
cb function A callback that will receive the message payload

createTab(key)

Basic tab creation

Kind: global function

Param Type Description
key String The unique key of the tab

removeTab(key)

Basic tab deletion

Kind: global function

Param Type Description
key Stirng The unique key of the tab

list(key, data)

Creates a new simple list TODO push, remove

Kind: global function

Param Type Description
key String The key of the tab
data Array The array representing the list

indexedList(key, data)

Creates a new indexed list, usefull for O(1) accessing and performance

Kind: global function

Param Type Description
key String The key of the tab
data Object The indexed object

indexedListItem(key, itemKey, data)

Creates/Update an element in the indexed list, based on the itemKey

Kind: global function

Param Type Description
key String The key of the tab
itemKey String The key of the item
data Any The value of the item