{"id":21363689,"url":"https://github.com/kevinokerlund/tablink","last_synced_at":"2025-03-16T07:13:14.696Z","repository":{"id":82290419,"uuid":"132645398","full_name":"kevinokerlund/tablink","owner":"kevinokerlund","description":"🔗 Dispatch data and events to other browser tabs on the same domain.","archived":false,"fork":false,"pushed_at":"2020-08-28T01:09:34.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-22T19:36:48.968Z","etag":null,"topics":["browser-tabs","dispatch","emitter","localstorage"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kevinokerlund.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"publiccode":null,"codemeta":null}},"created_at":"2018-05-08T17:54:52.000Z","updated_at":"2018-05-09T23:23:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"61a1576a-102d-4a63-a4b5-045232793f10","html_url":"https://github.com/kevinokerlund/tablink","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinokerlund%2Ftablink","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinokerlund%2Ftablink/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinokerlund%2Ftablink/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinokerlund%2Ftablink/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kevinokerlund","download_url":"https://codeload.github.com/kevinokerlund/tablink/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243836028,"owners_count":20355616,"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":["browser-tabs","dispatch","emitter","localstorage"],"created_at":"2024-11-22T06:20:44.927Z","updated_at":"2025-03-16T07:13:14.673Z","avatar_url":"https://github.com/kevinokerlund.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TabLink\nDispatch data and events to other browser tabs on the same domain.\n\n```bash\nnpm install tablink\n```\n\n## API\n\n### Dispatching\nSend a message to all other open tabs.\nIf the optional argument `includeOwnTab` is set to `true`,\nthe event will also be handled in the current tab doing the dispatching.\n\n```javascript\ntablink.dispatch(type, payload[, includeOwnTab]);\n```\n\n**`type`**  \nA case-sensitive string representing the event type.\n\n**`payload`**  \nA string or an object of data. Anything that can be sent through `JSON.stringify/parse`.\n\n**`includeOwnTab`**  \nOptional boolean. If `true`, the event will also be handled on the current tab.\n\n**Example:**\n```javascript\ntablink.dispatch('DISPLAY_LOGOUT_MODAL', {\n  type: 'SESSION_TIMEOUT'\n}, true);\n```\n\n---\n\n### Event listeners\n\n```javascript\ntablink.on(type, listener);\n```\n\n**`type`**_(String)_  \nA case-sensitive string representing the event type to listen for.\n\n**`listener`** _(Function)_  \nA callback function that receives the `payload` as its argument.  \n\nTo remove the listener, invoke the function returned by `on`.\n\n**Example:**\n```javascript\nlet unsubscribe = tablink.on('DISPLAY_LOGOUT_MODAL', (payload) =\u003e {\n  showModal(payload.type);\n});\n\n// to stop listening\nunsubscribe();\n```\n\n### Subscribing to all events\n\n```javascript\ntablink.subscribe(listener)\n```\n\n**`listener`** _(Function)_  \nThe callback to be invoked any time an action has been dispatched\n\nAdds a change listener. It will be called any time any action is dispatched.\nTo unsubscribe, invoke the function returned by subscribe.\n\n**Example:**\n```javascript\nlet unsubscribe = tablink.subscribe((type, payload) =\u003e {\n\tswitch (type) {\n\t\tcase 'TEST':\n\t\t\t// When a type of TEST is dispatched...\n\t\t\tbreak;\n\t}\n});\n\n// To unsubscribe\nunsubscribe();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevinokerlund%2Ftablink","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkevinokerlund%2Ftablink","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevinokerlund%2Ftablink/lists"}