61 |
* dispatchEvent(event) |
* dispatchEvent(event) |
62 |
|
|
63 |
This method takes an Event() instance and passes it to the |
This method takes an Event() instance and passes it to the |
64 |
EventController for propogation throughout the event model. |
EventController for propagation throughout the event model. |
65 |
|
|
66 |
For example, take our donut factory class. When fresh donuts are |
For example, take our donut factory class. When fresh donuts are |
67 |
available, it might dispatch the 'FreshDonutsReady': |
available, it might dispatch the 'FreshDonutsReady': |
72 |
to receive that event in order to dispatch it. In other words, |
to receive that event in order to dispatch it. In other words, |
73 |
DonutFactory doesn't care what happens when the FreshDonutsReady event |
DonutFactory doesn't care what happens when the FreshDonutsReady event |
74 |
is raised. |
is raised. |
75 |
|
|
76 |
|
As of GNUe-Common 0.5.0, dispatchEvent can be passed a string, followed |
77 |
|
by an arbitrary number of named parameters. This will implicitly create |
78 |
|
an event. For example, the following two statements are now equivalent: |
79 |
|
|
80 |
|
self.dispatchEvent(Event('FreshDonutsReady',quantity=48)) |
81 |
|
|
82 |
|
self.dispatchEvent('FreshDonutsReady',quantity=48) |
83 |
|
|
84 |
|
If you need a result or an error code from an event, you will still need |
85 |
|
to explicitly create an event to pass to dispatchEvent. |
86 |
|
|
87 |
|
|
88 |
|
|
89 |
Event |
Event |
101 |
|
|
102 |
Event.x = 1 |
Event.x = 1 |
103 |
Event.y = 2 |
Event.y = 2 |
104 |
Event.color = 'Blue'1 |
Event.color = 'Blue' |
105 |
|
|
106 |
|
|
107 |
An event has the following methods/attributes: |
An event has the following methods/attributes: |