{"action":"created","issue":{"url":"https://api.github.com/repos/fponticelli/hxelectron/issues/19","repository_url":"https://api.github.com/repos/fponticelli/hxelectron","labels_url":"https://api.github.com/repos/fponticelli/hxelectron/issues/19/labels{/name}","comments_url":"https://api.github.com/repos/fponticelli/hxelectron/issues/19/comments","events_url":"https://api.github.com/repos/fponticelli/hxelectron/issues/19/events","html_url":"https://github.com/fponticelli/hxelectron/issues/19","id":172415266,"number":19,"title":"class methods vs. instance methods","user":{"login":"clue4gd","id":13981719,"avatar_url":"https://avatars.githubusercontent.com/u/13981719?v=3","gravatar_id":"","url":"https://api.github.com/users/clue4gd","html_url":"https://github.com/clue4gd","followers_url":"https://api.github.com/users/clue4gd/followers","following_url":"https://api.github.com/users/clue4gd/following{/other_user}","gists_url":"https://api.github.com/users/clue4gd/gists{/gist_id}","starred_url":"https://api.github.com/users/clue4gd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clue4gd/subscriptions","organizations_url":"https://api.github.com/users/clue4gd/orgs","repos_url":"https://api.github.com/users/clue4gd/repos","events_url":"https://api.github.com/users/clue4gd/events{/privacy}","received_events_url":"https://api.github.com/users/clue4gd/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-08-22T10:12:03Z","updated_at":"2016-08-26T15:03:33Z","closed_at":null,"body":"Hi,\r\n\r\ncurrently am trying to set up a connection between the renderer and main process, in particular sending an async event from renderer to main process. Calling Ipc.send seems to work fine, but how to add the listener to that class for the callback since 'on' and 'addListener' are instance methods?\r\nTrying to add a constructor function to the ipc class and instantiate the ipcrender results in an error.\r\n\r\nThanks in advance!\r\n\r\nBest\r\nChris\r\n"},"comment":{"url":"https://api.github.com/repos/fponticelli/hxelectron/issues/comments/242760740","html_url":"https://github.com/fponticelli/hxelectron/issues/19#issuecomment-242760740","issue_url":"https://api.github.com/repos/fponticelli/hxelectron/issues/19","id":242760740,"user":{"login":"clue4gd","id":13981719,"avatar_url":"https://avatars.githubusercontent.com/u/13981719?v=3","gravatar_id":"","url":"https://api.github.com/users/clue4gd","html_url":"https://github.com/clue4gd","followers_url":"https://api.github.com/users/clue4gd/followers","following_url":"https://api.github.com/users/clue4gd/following{/other_user}","gists_url":"https://api.github.com/users/clue4gd/gists{/gist_id}","starred_url":"https://api.github.com/users/clue4gd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clue4gd/subscriptions","organizations_url":"https://api.github.com/users/clue4gd/orgs","repos_url":"https://api.github.com/users/clue4gd/repos","events_url":"https://api.github.com/users/clue4gd/events{/privacy}","received_events_url":"https://api.github.com/users/clue4gd/received_events","type":"User","site_admin":false},"created_at":"2016-08-26T15:03:33Z","updated_at":"2016-08-26T15:03:33Z","body":"I found a work around for it, which is basically the same stuff which is done in hxnodejs. To get around the issue that you have to deal with some instance and class methods, i created a helper class for the required modules which has static class members. An example can be found below: \r\n\r\n`\r\n@:native(\"global)\r\nextern class Electron {\r\n   static var ipcRenderer(get,never):Ipc;\r\n   private static inline function get_ipcRenderer():Ipc return untyped __js__(\"require(\\\"electron\\\").ipcRenderer\");\r\n`\r\nAdditionally i removed the static keyword for the functions 'send', 'sendSync' and `sendToHost` which is not needed. You are able to use the ipcRenderer module by `Electron.ipcRenderer`. \r\n\r\nI read about the other issue which was mentioned #17 regarding the jsRequire and inheritance. I think by using this kind of helper class, you can easily define another static member with another code require injection and you are fine, e.g.\r\n\r\n\r\n`\r\n@:native(\"global)\r\nextern class Electron {\r\n   static var ipcRenderer(get,never):Ipc;\r\n   private static inline function get_ipcRenderer():Ipc return untyped __js__(\"require(\\\"electron\\\").ipcRenderer\");\r\n\r\n  static var ipcMain(get,never):Ipc;\r\n  private static inline function get_ipcMain():Ipc return untyped __js__(\"require(\\\"electron\\\").ipcMain\");\r\n`\r\nSo you are not using the @:jsRequire of the Ipc class (which could be removed if you didn't use them directly), instead you define your import here. Didn't tested it but i think i should work fine. :)"}}
{"actor":{"display_login":"clue4gd"}}