krakenjs / zoid

Cross domain components
Apache License 2.0
2.03k stars 248 forks source link

Parent to child messaging feature #61

Closed marcelolorenzati closed 7 years ago

marcelolorenzati commented 7 years ago

xcomponent defines child to parent but no parent to child messaging that would be of great value to have parent to iframes comunicated.

bluepnume commented 7 years ago

@marcelolorenzati this is exactly what we have planned through https://github.com/krakenjs/xcomponent/issues/54 :)

For now though, you could just pass a callback up to the parent with the functions you want to expose:

Parent:

MyComponent.render({
    sendFunctionsToParent: function(obj) {

        // Now my parent window has all of the functions from the child
        obj.foo();
    }
});

Child:

window.xprops.sendFunctionsToParent({
    foo: function() { ... },
    bar: function() { ... }
});