1 // RUNNABLE_PHOBOS_TEST
7 void watch(string msg, int i)
9 writefln("Observed msg '%s' and value %s", msg, i);
12 void watch2(int i, int j)
14 writefln("Observed msg %s,%s", i, j);
20 int value() { return _value; }
26 // call all the connected slots with the two parameters
27 emit("setting new value", v);
32 // Mix in all the code we need to make Foo into a signal
33 mixin Signal!(string, int);
42 Observer o = new Observer;
44 a.value = 3; // should not call o.watch()
45 a.connect(&o.watch); // o.watch is the slot
46 a.value = 4; // should call o.watch()
47 a.disconnect(&o.watch); // o.watch is no longer a slot
48 a.value = 5; // so should not call o.watch()
49 a.connect(&o.watch); // connect again
50 a.value = 6; // should call o.watch()
51 delete o; // destroying o should automatically disconnect it
52 a.value = 7; // should not call o.watch()
55 /******************************************/
59 mixin Signal!(int, int) click;
60 mixin Signal!(char) keyDown;
65 Observer o = new Observer();
66 Input a = new Input();
67 a.click.connect(&o.watch2);
71 /******************************************/
82 writefln("Base3 dtor!");
88 mixin Signal!(Args3) A;
89 mixin Signal!(Args3) B;
93 writefln("Test3 dtor");
100 auto test = new Test3;
104 /******************************************/