Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
|
xojo:objectnotifier:start [2021/04/02 11:11] mz |
xojo:objectnotifier:start [2021/04/06 07:27] (aktuell) mz [Object notification] |
||
|---|---|---|---|
| Zeile 4: | Zeile 4: | ||
| <WRAP round download 40%> | <WRAP round download 40%> | ||
| - | {{ : | + | **{{ : |
| {{ : | {{ : | ||
| Zeile 10: | Zeile 10: | ||
| - | This works similar to the built-in interfaces dataNotifier and dataNotificationReceiver.\\ | + | This works similar to the built-in interfaces |
| However the **ObjectChanged** method receives two parameters: an **Object** from the notifier and any **info** from the original subscriber.\\ | However the **ObjectChanged** method receives two parameters: an **Object** from the notifier and any **info** from the original subscriber.\\ | ||
| - | The **notifier** may send himself by setting " | + | The **notifier** may send himself by setting " |
| The **subscriber** stores any sort of (static) information together with the callback-address when subscribing by // | The **subscriber** stores any sort of (static) information together with the callback-address when subscribing by // | ||
| This info may be a simple index number, but it can also be a whole object (means a reference to an object) so that the receiver can distinguish which subscription called him. | This info may be a simple index number, but it can also be a whole object (means a reference to an object) so that the receiver can distinguish which subscription called him. | ||
| Zeile 20: | Zeile 20: | ||
| Simply instantiate this class and call their members like: | Simply instantiate this class and call their members like: | ||
| - | + | Declare: | |
| - | | + | |
| private property onb as ObjectNotifierBox | private property onb as ObjectNotifierBox | ||
| - | ----- | + | in //Constructor// Method: |
| - | | + | |
| onb = new ObjectNotifierBox | onb = new ObjectNotifierBox | ||
| - | ----- | + | Actual implementation of the // |
| - | Method: | + | |
| Sub addObjectNotificationReceiver(receiver as objectNotificationReceiver, | Sub addObjectNotificationReceiver(receiver as objectNotificationReceiver, | ||
| | | ||
| End Sub | End Sub | ||
| - | + | ||
| - | Method: | + | |
| Sub removeObjectNotificationReceiver(receiver As objectNotificationReceiver) | Sub removeObjectNotificationReceiver(receiver As objectNotificationReceiver) | ||
| | | ||
| End Sub | End Sub | ||
| - | For calling all receivers write: | + | For calling all subscribed |
| onb.callReceivers(me) | onb.callReceivers(me) | ||
| Zeile 43: | Zeile 39: | ||
| Instead of " | Instead of " | ||
| + | <WRAP round important 100%> | ||
| + | Be careful with // | ||
| + | < | ||
| + | xy.addObjectNotificationReceiver(me, | ||
| + | xy.addObjectNotificationReceiver(me, | ||
| + | </ | ||
| + | Because // | ||
| + | It's therefore not possible to delete only the second entry (with //info// 2). | ||
| + | |||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | ====== Sourcecode ====== | ||
| {{ : | {{ : | ||
| Zeile 102: | Zeile 112: | ||
| Properties | Properties | ||
| | | ||
| - | mInfos() As Variant | + | |
| - | mReceivers() As objectNotificationReceiver | + | |
| | | ||
| End Class | End Class | ||