How to use the post-robot/dist/post-robot.sendToParent function in post-robot

To help you get started, we’ve selected a few post-robot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github krakenjs / zoid / src / child.js View on Github external
this.props[key] = function() {
                        let args = Array.prototype.slice.call(arguments);
                        
                        try {
                            JSON.stringify(args);
                        } catch (err) {
                            throw new Error(`Can not serialize arguments passed to props.${key}`);
                        }
                        
                        return postRobot.sendToParent('xcomponent_prop_function', {
                            key: key,
                            args: args
                        });
                    }
                }
github krakenjs / zoid / src / child.js View on Github external
constructor(component, options = {}) {
        this.validate(options);

        this.component = component;
        this.enter = options.enter || noop;
        this.exit = options.exit || noop;
        
        postRobot.sendToParent('xcomponent_init').then(data => {
            
            this.id = data.id;
            this.props = data.props;

            for (let key of Object.keys(this.component.props)) {
                let prop = this.component.props[key];
                
                if (prop.type === 'function') {
                    this.props[key] = function() {
                        let args = Array.prototype.slice.call(arguments);
                        
                        try {
                            JSON.stringify(args);
                        } catch (err) {
                            throw new Error(`Can not serialize arguments passed to props.${key}`);
                        }