8000 Implement full IPC API on render process by rdickert · Pull Request #73 · electron-webapps/meteor-electron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Implement full IPC API on render process #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions app/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,29 @@ ElectronImplementation = {
* Invokes _callback_ when the specified IPC event is fired.
*
* @param {String} event - The name of an event.
* @param {Function} callback - A function to invoke when `event` is triggered. Takes no arguments
* and returns no value.
* @param {Function} callback - A function to invoke when `event` is triggered. Called with
* the signature (event, ...args) - see http://electron.atom.io/docs/v0.37.2/api/ipc-renderer/#sending-messages
*/
onEvent: function(event, callback) {
var listeners = this._eventListeners[event];
if (!listeners) {
listeners = this._eventListeners[event] = [];
ipc.on(event, function() {
_.invoke(listeners, 'call');
ipc.on(event, function(/* event, ...args */) {
_.invoke(listeners, 'apply', null, arguments);
});
}
listeners.push(callback);
},

_eventListeners: {}
_eventListeners: {},

/**
* Send an event to the main Electron process.
*
* @param {String} event - The name of an event.
* @param {...*} arg - additional arguments to pass to event handler.
*/
send: function(/* event , ...args */) {
ipc.send.apply(null, arguments);
},
};
0