Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ScarletsFiction/SFIntercom
Client-side cross-tab communication with same domain
https://github.com/ScarletsFiction/SFIntercom
broadcast browser cross-tab-communication javascript js
Last synced: 2 months ago
JSON representation
Client-side cross-tab communication with same domain
- Host: GitHub
- URL: https://github.com/ScarletsFiction/SFIntercom
- Owner: ScarletsFiction
- License: mit
- Created: 2018-07-29T07:01:27.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-01-29T18:36:47.000Z (almost 5 years ago)
- Last Synced: 2024-08-02T20:46:23.761Z (5 months ago)
- Topics: broadcast, browser, cross-tab-communication, javascript, js
- Language: JavaScript
- Homepage:
- Size: 8.79 KB
- Stars: 8
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-indo-projects - SFIntercom - Communication between browser's tabs with same domain. (JavaScript)
- awesome-indonesia-repo - SFIntercom - Communication between browser's tabs with same domain. (JavaScript)
- awesome-vietnam-repo - SFIntercom - Communication between browser's tabs with same domain. (JavaScript)
README
[![Written by](https://img.shields.io/badge/Written%20by-ScarletsFiction-%231e87ff.svg)](LICENSE)
[![Software License](https://img.shields.io/badge/License-MIT-brightgreen.svg)](LICENSE)# SFIntercom
SFIntercom is a client-side library that allow cross-tab communication with same domain.
It can broadcast to all listener on a different tab or window, but can't broadcast to other browser instance.This library was useful for syncronizing message, notification, and other data.
## Sample Usage
```js
// First tab
var client1 = new SFIntercom();
client1.on('log', console.log);
client1.on('warn', console.warn);// Second tab
var client2 = new SFIntercom();
client2.on('log', console.log);
client2.emit('log', 'Hello from second tab'); // Broadcast to all except this tab// Third tab
var broadcaster = new SFIntercom();
broadcaster.emit('log', "Hello from third tab"); // Broadcast to all
broadcaster.emit('warn', "Hello warn"); // Broadcast to all who listen to 'warn'
```## Contribution
If you want to help in SFIntercom library, please fork this project and edit on your repository, then make a pull request to here.
Keep the code simple and clear.
## License
SFIntercom is under the MIT license.
But don't forget to put the a link to this repository.