View source code
Display the source code in std/signals.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone.

Module std.signals

Signals and Slots are an implementation of the Observer Pattern. Essentially, when a Signal is emitted, a list of connected Observers (called slots) are called.

There have been several D implementations of Signals and Slots. This version makes use of several new features in D, which make using it simpler and less error prone. In particular, it is no longer necessary to instrument the slots.

References

A Deeper Look at Signals and Slots
Observer pattern
Wikipedia
Boost Signals
Qt

There has been a great deal of discussion in the D newsgroups over this, and several implementations:

signal slots library
Signals and Slots in D
Dynamic binding -- Qt's Signals and Slots vs Objective-C
Dissecting the SS
about harmonia
Another event handling module
Suggestion: signal/slot mechanism
Signals and slots?
Signals and slots ready for evaluation
Signals & Slots for Walter
Signal/Slot mechanism?
Modern Features?
Delegates vs interfaces
The importance of component programming (properties, signals and slots, etc)
signals and slots

Bugs

Slots can only be delegates referring directly to class or interface member functions. If a delegate to something else is passed to connect(), such as a struct member function, a nested function, a COM interface, a closure, undefined behavior will result.

Not safe for multiple threads operating on the same signals or slots.

Templates

NameDescription
Signal Mixin to create a signal within a class object.

Authors

Walter Bright

License

Boost License 1.0.