/ts-signals

Typescript Pub/Sub Library inspired by QT signals/slots

Primary LanguageTypeScriptMozilla Public License 2.0MPL-2.0

ts-signals

Build Status

NOTE: This project is not actively maintained

Concept

  • A Signal is essentially a mini-dispatcher specific to one event, with its own array of listeners.
  • A Signal gives an event a concrete membership in a class.
  • Listeners subscribe to real objects, not to string-based channels.
  • Signals are inspired by C# events and signals/slots in Qt.

Example

interface Photo {
  name : String;
  url : String;
}		

interface PhotoAlbum {
  thumbnailClick : TypedSignal<Photo>;
}		

interface PhotoFrame {
  show(photo : Photo);
}

// displays a photo in a frame when the thumbnail is clicked
photoAlbum.thumbnailClick.add(photo => photoFrame.show(photo));