src/courier/PostMessageCourier.js
function _initializeCommunication(options) {
                var mapping;
                var onmessage;

                // Grab the event channel and initialize a new mapper
                this.eventChannel = options.eventChannel || new Channels({
                    events: options.events,
                    commands: options.commands,
                    reqres: options.reqres
                });
                this.mapper = new PostMessageMapper(this.eventChannel);

                // Bind the mapping method to the mapper
                mapping = this.mapper.toEvent.bind(this.mapper);
                // Create the message handler which uses the mapping method
                onmessage = _createMessageHandler(mapping).bind(this);

                // Initialize a message channel with the message handler
                this.messageChannel = new PostMessageChannel(options, onmessage);
            }
function _initializeCommunication(options) {
                var mapping;
                var onmessage;

                // Grab the event channel and initialize a new mapper
                this.eventChannel = options.eventChannel || new Channels({
                    events: options.events,
                    commands: options.commands,
                    reqres: options.reqres
                });
                this.mapper = new PostMessageMapper(this.eventChannel);

                // Bind the mapping method to the mapper
                mapping = this.mapper.toEvent.bind(this.mapper);
                // Create the message handler which uses the mapping method
                onmessage = _createMessageHandler(mapping).bind(this);

                // Initialize a message channel with the message handler
                this.messageChannel = new PostMessageChannel(options, onmessage);
            }
function _initializeCommunication ( options ) { var mapping ; var onmessage ; // Grab the event channel and initialize a new mapper this . eventChannel = options . eventChannel || new Channels ( { events : options . events , commands : options . commands , reqres : options . reqres } ) ; this . mapper = new PostMessageMapper ( this . eventChannel ) ; // Bind the mapping method to the mapper mapping = this . mapper . toEvent . bind ( this . mapper ) ; // Create the message handler which uses the mapping method onmessage = _createMessageHandler ( mapping ) . bind ( this ) ; // Initialize a message channel with the message handler this . messageChannel = new PostMessageChannel ( options , onmessage ) ; }
Method for initializing the communication elements
@param {Object} [options.eventChannel] - optional events channel to be used (if not supplied, a new one will be created OR optional events, optional commands, optional reqres to be used
@private
Method for initializing the communication elements