
Security News
New CVE Forecasting Tool Predicts 47,000 Disclosures in 2025
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
message-event-channel
Advanced tools
An event driven fault tolerant library for communicating between contexts using MessageChannel.
An event driven fault tolerant library for communicating between contexts using MessageChannel.
Using npm:
npm install message-event-channel --save
Using cdn:
<script src="https://unpkg.com/message-event-channel/dist/message-event-channel.umd.js"></script>
import { ClientConnection } from 'message-event-channel';
const connection = new ClientConnection();
or
const mc = require('message-event-channel');
const connection = new mc.ClientConnection();
or
<script src="https://unpkg.com/message-event-channel/dist/message-event-channel.umd.js"></script>
<script>
const connection = new mc.ClientConnection();
</script>
/parent.html
import { ServerConnection } from 'message-event-channel';
const frame = document.querySelector('iframe');
const connection = new ServerConnection(frame);
connection.emit('my-event', {hello: 'world'});
frame.src = "./frame.html";
/frame.html
import { ClientConnection } from 'message-event-channel';
const connection = new ClientConnection();
connection.on('my-event', (payload)=>{
// {hello: "world"}
console.log(payload)
});
/parent.html
import { ServerConnection } from 'message-event-channel';
const connection = new ServerConnection(frame);
connection.request('some-data')
.then(payload => {
// {hello: "world"}
console.log(payload)
})
frame.src = "./frame.html";
/frame.html
import { ClientConnection } from 'message-event-channel';
const connection = new ClientConnection();
connection.on('some-payload', (payload, resolve, reject)=>{
resolve({hello: 'world'})
});
/parent.html
import { Operator } from 'message-event-channel';
const operator = new Operator();
const connection1 = operator.connect(frame1);
const connection2 = operator.connect(frame2);
const connection3 = operator.connect(frame3);
operator.emit('send-to-all');
/parent.html
import { ServerConnection } from 'message-event-channel';
const connection = new ServerConnection(frame);
connection.close();
{
targetOrigin: '*' // limit the connection to a particular origin (reccomended)
onload: true, // if the connection should be initialised by an onload event or manually using init()
timeout: 2000, // default time it takes for requests to timeout
debug: false, // used to enable useful behind-the-scenes info
connectionTimeout: 2000 // will trigger the CONNECTION_TIMEOUT event if a connection hasn't been established by this time, can be set to false.
clientInitiates: false // Server setting - waits for a init() trigger from the child frame before initiating.
}
FAQs
An event driven fault tolerant library for communicating between contexts using MessageChannel.
The npm package message-event-channel receives a total of 2,292 weekly downloads. As such, message-event-channel popularity was classified as popular.
We found that message-event-channel demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers 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
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.