Package to communicate between iframes and application.
npm install iframessa
<iframe src="about.html" name="about"></iframe>
const iframessa = require('iframessa');
iframessa.getter('userName', ({ data, sender }) => {
return 'Matheus Cristian';
});
const iframessa = require('iframessa');
iframessa.register('about');
iframessa.get('userName').then(({ data, sender }) => {
console.log(data); // Matheus Cristian
console.log(sender); // parent object
}, data);
const iframessa = require('iframessa');
iframessa.emit('action', 'logout');
This will emit a 'action'
event to your parent with the data 'logout'
.
Note that the data can be an object as well.
const iframessa = require('iframessa');
iframessa.on('action', ({ data, sender }) => {
console.log(data); // logout
});
You can emit something to a specific child window with iframessa.modules.about.emit(event, data);