
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Share an event emitter among chrome runtime components
Because managing anonymous events is not fun
This module is used by chromiumify
$ npm install chrome-bus
This usage is when you have a background page that you want to communicate to.
var createBus = require('chrome-bus')
var bus = createBus()
bus.on('hello', function (msg) {
console.log('msg=', msg)
})
bus.emit('hello', Date.now())
Communicating with webviews in chrome apps is not straight forward as a channel between the host page and the view needs to be created.
There is also no way for a page to know if it is being hosted in a webview.
So there are conventions for working around this.
Below are the main parts you need to understand but see the sample app for a working sample
var view = document.getElementById('wv')
view.addEventListener('contentload', function (evt) { // You have to wait for the webview to load before attaching the eventbus
var wvbus = createBus(view) // Pass in the webview when creating the bus
wvbus.on('goodbye', function (msg) {
assert.ok('Message Received')
console.log('msg=', msg)
})
wvbus.emit('hello', Date.now())
})
In the HTML for the view ensure that the URI to the location of the view contains a bookmark to fragment
<webview src="webview.html#fragment" id="wv" partition="wvevent" autosize="true" minwidth="500" minheight="450"></webview>
var bus = createBus() // no additional parameter is allowed as the #fragment tag is used to create a namespace
bus.on('hello', function (msg) {
assert.ok('Message Received')
console.log('msg=', msg)
bus.emit('goodbye', Date.now())
})
FAQs
Share an event emitter among chrome runtime components
The npm package chrome-bus receives a total of 5 weekly downloads. As such, chrome-bus popularity was classified as not popular.
We found that chrome-bus demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.