{"id":14978555,"url":"https://github.com/marcbachmann/electron-rpc","last_synced_at":"2025-09-13T23:32:17.558Z","repository":{"id":35587243,"uuid":"39859989","full_name":"marcbachmann/electron-rpc","owner":"marcbachmann","description":":arrows_clockwise: A lightweight wrapper around the electron ipc module.","archived":false,"fork":false,"pushed_at":"2023-12-15T20:17:14.000Z","size":8,"stargazers_count":60,"open_issues_count":1,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-03T04:28:38.750Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marcbachmann.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2015-07-28T22:03:49.000Z","updated_at":"2024-11-04T12:33:38.000Z","dependencies_parsed_at":"2023-12-15T21:55:43.626Z","dependency_job_id":null,"html_url":"https://github.com/marcbachmann/electron-rpc","commit_stats":{"total_commits":16,"total_committers":4,"mean_commits":4.0,"dds":0.25,"last_synced_commit":"0dc47867ed03f8ab764bfbb01ff5180c9ecec399"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcbachmann%2Felectron-rpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcbachmann%2Felectron-rpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcbachmann%2Felectron-rpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcbachmann%2Felectron-rpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcbachmann","download_url":"https://codeload.github.com/marcbachmann/electron-rpc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232931886,"owners_count":18598663,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-24T13:57:54.004Z","updated_at":"2025-01-07T20:07:09.483Z","avatar_url":"https://github.com/marcbachmann.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# electron-rpc\n\nA lightweight wrapper around the ipc module of electron\n\nThis module is only compatible with [Electron](https://github.com/atom/electron). It won't work in nodejs directly.\n\n\nPlease use electron-rpc@v2.0.0 if you're using [electron \u003e= v0.35.0](https://github.com/atom/electron/releases/tag/v0.35.0). The ipc module api changed with that version.\n\n\n#### Server API\n```js\nconst Server = require('electron-rpc/server')\nconst server = new Server()\n\nserver.configure(webContents)\nserver.send(action[, body])\nserver.on(action, callback)\nserver.destroy()\n```\n\n#### Client API\n```js\nconst Client = require('electron-rpc/client')\nconst client = new Client()\n\nclient.request(action[, body][, callback])\nclient.on(action, callback)\nclient.removeListener(action, callback)\nclient.destroy()\n```\n\n#### Usage\n##### Server side\n```js\nconst Server = require('electron-rpc/server')\nconst app = new Server()\napp.configure(window.webContents) // pass a BrowserWindow.webContents[1] object\n\napp.on('some-action', (req, next) =\u003e {\n  // req consists of id, action, body\n  someAsyncRequest((err, data) =\u003e {\n    if (err) return next(err)\n    next(null, data)\n  })\n})\n\napp.on('some-action-without-callback', function(req){\n  console.log('foo')\n})\n\n// You can also send messages without triggering a request on the client\napp.send('some-server-message', 'bar')\n```\n\nHere's the documentation about the [BrowserWindow.webContents](https://github.com/atom/electron/blob/master/docs/api/browser-window.md#browserwindowwebcontents) object.\n\n##### Client side\n```js\nconst Client = require('electron-rpc/client')\nclient = new Client()\n\nclient.request('some-action', (err, body) =\u003e {\n  console.log('Error from someAsyncRequest:', err)\n  console.log('Body from someAsyncRequest:', body)\n})\n\nclient.request('some-action-without-callback')\n\nclient.on('some-server-message', (err, body) =\u003e {\n  console.log('foo:', body)\n})\n```\n\nTo close the connections, you can use `server.destroy()` or `client.destroy()`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcbachmann%2Felectron-rpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcbachmann%2Felectron-rpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcbachmann%2Felectron-rpc/lists"}