How would you implement this in D? (signals & slots)

Vadim Lopatin via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Feb 3 02:26:29 PST 2016


On Monday, 1 February 2016 at 21:40:45 UTC, Enjoys Math wrote:
> module signals_and_slots;
> How do you implement this template called like:
> void onColorChange(in Color) {
>    // do something with color
> }
> auto slots = Slots!(void delegate(in Color), Color);
> slots.connect(&onColorChange);
> auto color = Color(0.0, 1.0, 1.0, 1.0);
> slots.call(color);

Signals in DlangUI:

https://github.com/buggins/dlangui/blob/master/src/dlangui/core/signals.d




More information about the Digitalmars-d-learn mailing list