{"id":21009001,"url":"https://github.com/avin/commutator","last_synced_at":"2025-05-15T02:32:51.576Z","repository":{"id":86506862,"uuid":"500448940","full_name":"avin/commutator","owner":"avin","description":"Making RPC calls with postmessages","archived":false,"fork":false,"pushed_at":"2024-04-11T21:28:22.000Z","size":223,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-10T23:07:08.768Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/avin.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,"dei":null}},"created_at":"2022-06-06T13:40:59.000Z","updated_at":"2023-11-13T14:08:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"55b1b21a-42a7-49a4-ad1b-a41e12a98a54","html_url":"https://github.com/avin/commutator","commit_stats":{"total_commits":7,"total_committers":1,"mean_commits":7.0,"dds":0.0,"last_synced_commit":"2d74684b34b135958bc14eab6ed78f5d403cc21b"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avin%2Fcommutator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avin%2Fcommutator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avin%2Fcommutator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avin%2Fcommutator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/avin","download_url":"https://codeload.github.com/avin/commutator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225324104,"owners_count":17456460,"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-11-19T09:15:07.389Z","updated_at":"2024-11-19T09:15:08.027Z","avatar_url":"https://github.com/avin.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Commutator\n\nMaking RPC calls (asynchronous method calls) between browser windows or iframes.\n\n## Install\n```\nnpm install commutator\n```\n\n## Usage\n\n**parent.js**\n\n```js\nimport { Commutator } from 'commutator';\n\nconst rpc = new Commutator({\n  // The window you want to talk to:\n  target: myIframe.contentWindow,\n  // This should be unique for each of your producer\u003c-\u003econsumer pairs:\n  serviceId: 'my-awesome-service',\n});\n\nrpc.expose('add', (data) =\u003e data.a + data.b);\n```\n\nDestroy the instance\n```js\nrpc.destroy();\n```\n\nRemove expose handler\n```js\nconst handleAdd = (data) =\u003e data.a + data.b\n// Expose\nrpc.expose('add', handleAdd);\n// Unexpose\nrpc.unexpose('add', handleAdd);\n```\n\n**iframe.js**\n\n```js\nimport { Commutator } from 'commutator';\n\nconst rpc = new Commutator({\n  target: window.parent,\n  serviceId: 'my-awesome-service',\n});\n\nrpc.call('add', { a: 3, b: 5 }).then(result =\u003e console.log('3 + 5 is', result));\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favin%2Fcommutator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Favin%2Fcommutator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favin%2Fcommutator/lists"}