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 12:43] mz |
xojo:objectnotifier:start [2021/04/06 09:27] (aktuell) mz [Object notification] |
||
---|---|---|---|
Zeile 3: | Zeile 3: | ||
<fs x-large> | <fs x-large> | ||
- | This works similar to the built-in interfaces dataNotifier and dataNotificationReceiver.\\ | + | <WRAP round download 40%> |
+ | **{{ : | ||
+ | |||
+ | {{ : | ||
+ | </ | ||
+ | |||
+ | |||
+ | 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. | ||
+ | The **// | ||
+ | Simply instantiate this class and call their members like: | ||
+ | Declare: | ||
+ | private property onb as ObjectNotifierBox | ||
+ | in // | ||
+ | onb = new ObjectNotifierBox | ||
+ | Actual implementation of the // | ||
+ | Sub addObjectNotificationReceiver(receiver as objectNotificationReceiver, | ||
+ | | ||
+ | End Sub | ||
- | {{ : | + | Sub removeObjectNotificationReceiver(receiver As objectNotificationReceiver) |
+ | onb.removeReceiver(receiver) | ||
+ | End Sub | ||
- | <WRAP round download 40%> | + | For calling all subscribed receivers write somewhere in your class: |
- | {{ : | + | |
+ | onb.callReceivers(me) | ||
+ | |||
+ | Instead of " | ||
+ | |||
+ | <WRAP round important 100%> | ||
+ | Be careful with // | ||
+ | <code> | ||
+ | xy.addObjectNotificationReceiver(me, | ||
+ | xy.addObjectNotificationReceiver(me, | ||
+ | </ | ||
+ | Because // | ||
+ | It's therefore not possible to delete only the second entry (with //info// 2). | ||
- | {{ : | ||
</ | </ | ||
+ | |||
+ | |||
+ | |||
+ | ====== Sourcecode ====== | ||
+ | |||
+ | {{ : | ||
Zeile 76: | Zeile 112: | ||
Properties | Properties | ||
| | ||
- | mInfos() As Variant | + | |
- | mReceivers() As objectNotificationReceiver | + | |
| | ||
End Class | End Class |