Receive wakeup events, including link clicks external to app
import wakeups from 'pear-wakeups'const stream = wakeups()
stream.on('data', (wakeup) => {
const { link, applink, entrypoint, fragment, query, linkData } = wakeup
//...
})wakeups((wakeup) => {
const { link, applink, entrypoint, fragment, query, linkData } = wakeup
//...
})A wakeup occurs in the following cases:
- when a trusted
pear://link is clicked and the application for that link is already open - when used with
pear run --detached pear://<key>[/data]
The listener function is called for every incoming wakeup with a wakeup object of the form:
{
type: 'pear/wakeup',
link: <String>,
linkData: <String>,
fragment: <String>,
entrypoint: <String>
}linkis thepear://link for the application receiving the wakeuplinkDatais everything after the key in thepear://link - this would bepathnameof aURLobject but without the leading slash (/). Givenpear://8ts9yz9dtucxzwbxafygnjasqe9ti3dt3w7rm6sbiu8prmidacao/some/more/stuffthedatastring would holdsome/more/stuff.fragmentis thefragmentpart ofpear://link#fragment(location hash without the#prefix).entrypointincludesentrypointofpear://link/some/entry/point(URL pathname).
Also returns a streamx Readable) stream.
Apache-2.0