New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

signals-slots

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

signals-slots

SignalJS is an implementation of signals/slots system in JavaScript.

  • 0.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Signals/Slots in JavaScript

SignalJS is a minimalist implementation of signals/slots system in JavaScript.

How to Use

Say I have an app called MyApp, it has two objects MyApp.X and MyApp.Y. Now, MyApp.Y wants to be notified if there are some events happened on MyApp.X. To accomplish this task, I just need the following few steps:

  1. Clone this repo and add signal.js to my HTML

    <script src="path/to/signal.js"></script>
    
  2. Create a signal and attach it to MyApp namespace, so it can be accessed by both MyApp.X and MyApp.Y

    MyApp.dummySignal = Signal.create('dummySignal');
    
  3. Connect MyApp.Y to the just created signal

    MyApp.Y.signalHandler = function(sender, data) {
        console.log('Received a dummySignal from sender with data');
    };
    
    MyApp.dummySignal.connect(MyApp.Y.signalHandler, MyApp.Y);
    
  4. Let MyApp.X send the signal when some event is happened

    MyApp.X.http.get('/data').
        success(function(response) {
            /*
             * Got new data, send signal to notify whomever is connected. In
             * this example, `MyApp.Y.signalHandler` will be called.
             */
            MyApp.dummySignal.emit(MyApp.X, response);
        });
    
  5. That's it!

Live DEMO

Keywords

FAQs

Package last updated on 01 Jun 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc