An open API service indexing awesome lists of open source software.

https://github.com/cristianoliveira/ifrone

A tiny wrapper around cross-window communication.
https://github.com/cristianoliveira/ifrone

iframe iframe-communication iframe-pubsub lightweight pubsub wrapper

Last synced: 11 months ago
JSON representation

A tiny wrapper around cross-window communication.

Awesome Lists containing this project

README

          

# ifrone.
[![NPM](https://img.shields.io/npm/v/ifrone.svg)](https://www.npmjs.com/package/ifrone)

A tiny wrapper around cross-window communication.

This feature is normally used for communication between a page host and an iframe.

## Example

```javascript




const iframe = document.getElementById('myiframe');
var iph = ifrone.connect({
from: window,
to: iframe.contentWindow,
host: '*'
})

iph.on('myIframeEvent', (event) => {
console.log('myIframeEvent', event);
})

setInterval(() => {
iph.send('myHostEvent', 'fooo')
}, 1000)

iph.ack('myHostEvent', (event) => {
console.log('on ack myHostEvent', event);
})



```

## Running tests

```
yarn test
```