JSPM

node-connect

0.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q22051F
  • License MIT

a simple way to connect objects

Package Exports

  • node-connect

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (node-connect) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

node-connect

a simple way to connect objects with their signal and slot in a Qt style

###Install

$ npm install node-connect

###Example

var events = require('events'),
    util = require('util'),
    connect = require('node-connect');

/**
 * `Sender`
 */
function Sender() {
  events.EventEmitter.call(this);
}
util.inherits(Sender, events.EventEmitter);

/**
 * `Receiver`
 */
function Receiver() {
  this.counter = 0;
}
Receiver.prototype.slot = function() {
  console.log('This a slot from `Receiver`');
  this.counter++;
  console.log('The counter is ', this.counter);
};

var sender = new Sender(),
    receiver = new Receiver();

connect(sender, 'signal', receiver, 'slot');
sender.emit('signal');
sender.emit('signal');

###API

####connect(sender, signal, receiver, slot)

binding the function receiver[slot] or slot to the signal of sender

###LICENSE

MIT