TypeScript Signals Released

Topics: General
Apr 3, 2013 at 1:14 PM
Signals are a light-weight, strongly typed messaging tool and we use them extensively in our game framework. And we’ve just released our TypeScript implementation for others to benefit from. It’s a conversion of js-signals by Miller Medeiros, which is of course in turn a conversion of AS3-Signals by Robert Penner.

You can get TypeScript-Signals from github.

If you are unfamiliar with Signals, how they work and how they compare to Events then this short summary is well worth a quick read, but to summarise:
  • 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.
  • Event string constants are no longer needed.
  • Signals are inspired by C# events and signals/slots in Qt.
I ported over all of the 18 unit tests to TypeScript as well. So you have plenty of examples: from adding a basic listener up to manual binding and dynamic context switching.

Apr 3, 2013 at 5:10 PM
I made a TS definition file for my SignalsLite.js - another JS version of AS3 Signals. I was actually planning to rewrite that for fun (with a slightly different API) in TypeScript to try to get greater type enforcement and even better performance out of it (it's no slouch now though), but it looks like you beat me to it! It's cool to see the pattern alive and well outside of AS3. :-)

Apr 3, 2013 at 6:12 PM
I'm not a huge fan of using definition files so prefer to recode into TypeScript, so it's all operating under the same roof so to speak - but nice work on SignalsLite :) I've been really impressed with how well TS Signals performs, which is all thanks to the js-signals author and Rob Penner really. They're just so more flexible and better than events.