xojo:objectnotifier:start

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

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>A simple subscribe-callback mechanism for inter-object communication</fs> <fs x-large>A simple subscribe-callback mechanism for inter-object communication</fs>
  
-This works similar to the built-in interfaces dataNotifier and dataNotificationReceiver.\\+<WRAP round download 40%> 
 +**{{ :xojo:objectnotifier:object_notification.zip |Object Notification interfaces and class  (xojo-binary-code folder)}}**\\ 
 + 
 +{{ :xojo:objectnotifier:objectnotification.pdf |Sourcecode as pdf}} 
 +</WRAP> 
 + 
 + 
 +This works similar to the built-in interfaces //dataNotifier// and //dataNotificationReceiver//.\\
 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 "me" as Object, or he sends simply the current data which have changed.\\+The **notifier** may send himself by setting "me" as Object, or he sends simply the current data which have been changed.\\
 The **subscriber** stores any sort of (static) information together with the callback-address when subscribing by //addObjectNotificationReceiver//.\\ The **subscriber** stores any sort of (static) information together with the callback-address when subscribing by //addObjectNotificationReceiver//.\\
 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 **//ObjectNotifierBox//** contains the complete implementation of the //objectNotifier// interface.\\
 +Simply instantiate this class and call their members like:
  
 +Declare:
 +  private property onb as ObjectNotifierBox
 +in //Constructor// Method:
 +  onb = new ObjectNotifierBox 
 +Actual implementation of the //objectNotifier// Interface:
 +  Sub addObjectNotificationReceiver(receiver as objectNotificationReceiver, optional info as Variant = nil)
 +     onb.addReceiver(receiver, info)
 +  End Sub
  
-{{ :xojo:objectnotifier:objectnotification-tree.png|}}+  Sub removeObjectNotificationReceiver(receiver As objectNotificationReceiver) 
 +     onb.removeReceiver(receiver) 
 +  End Sub
  
-<WRAP round download 40%> +For calling all subscribed receivers write somewhere in your class: 
-{{ :xojo:objectnotifier:object_notification.zip |Object Notification interfaces and class  (xojo-binary-code folder)}}\\+ 
 +  onb.callReceivers(me) 
 + 
 +Instead of "me" you may send any object you need, of course... 
 + 
 +<WRAP round important 100%> 
 +Be careful with //removing// if you have multiple subscriptions from the same object (perhaps with different //info//).\\ 
 +<code
 +xy.addObjectNotificationReceiver(me, 1) 
 +xy.addObjectNotificationReceiver(me, 2) 
 +</code> 
 +Because //removeObjectNotificationReceiver// obtains no //info// parameter, it cancels only the first object found in the array, thus acting as //fifo//.\\ 
 +It's therefore not possible to delete only the second entry (with //info// 2).
  
-{{ :xojo:objectnotifier:objectnotification.pdf |Sourcecode as pdf}} 
 </WRAP> </WRAP>
 +
 +
 +
 +====== Sourcecode ======
 +
 +{{ :xojo:objectnotifier:objectnotification-tree.png|}}
  
  
Zeile 76: Zeile 112:
   Properties   Properties
      
-  mInfos() As Variant +  Private mInfos() As Variant 
-  mReceivers() As objectNotificationReceiver+  Private mReceivers() As objectNotificationReceiver
      
   End Class   End Class
  • xojo/objectnotifier/start.1617360188.txt.gz
  • Zuletzt geändert: 2021/04/02 12:43
  • von mz