Use of Notification eventTag

For questions and postings not covered by the other forums
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Use of Notification eventTag

Postby ConvertFromOldNGs » Fri Aug 07, 2009 11:55 am

by JADE News >> Tue, 13 Jun 2000 2:59:17 GMT

Hi,

Given that one generally registers a particular class or object for a particular eventType, of what use is the eventTag parameter ? The Class Notification Online Help sites an index into an array as an example, and the User Notification Help offers even less of an explanation.

I'd be interested in hearing (okay, reading) how others use this.

darrell.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Use of Notification eventTag

Postby ConvertFromOldNGs » Fri Aug 07, 2009 11:55 am

by John Porter >> Tue, 13 Jun 2000 6:33:56 GMT

I've used it with timers, so I know which timer has gone off.

Cheers,
John P

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Use of Notification eventTag

Postby ConvertFromOldNGs » Fri Aug 07, 2009 11:55 am

by Darrell Duniam >> Tue, 13 Jun 2000 21:32:22 GMT

I assume you're registering multiple notifications for a single event, but with different eventTag values for each timer, therefore you'd be receiving multiple notifications for each causeEvent. Wouldn't it be more efficient to register a unique (User) event for each timer, thus you'd only receive a single notification for the causeEvent ? If so, isn't the eventTag superfluous ?

darrell.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Use of Notification eventTag

Postby ConvertFromOldNGs » Fri Aug 07, 2009 11:55 am

by John Porter >> Wed, 14 Jun 2000 0:24:54 GMT

Performance was not an issue, and I preferred to have a single method with "if eventTag=". -- jp

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Use of Notification eventTag

Postby ConvertFromOldNGs » Fri Aug 07, 2009 11:55 am

by Krull >> Tue, 13 Jun 2000 21:45:40 GMT
Given that one generally registers a particular class or object for a particular eventType, of what use is the eventTag parameter ? The Class Notification Online Help sites an index into an array as an example, and the User Notification Help offers even less of an explanation.

I'd be interested in hearing (okay, reading) how others use this.

The eventTag parameter identifies a particular event subscription and is useful when you have multiple subscriptions for the same eventType. When using instance level notifications, the notification target also identifies the specific event, but in some cases an even tag can be used to locate the associated 'item' that needs to be refreshed more conveniently or efficiently. For example, you might register to be notified for system notifications such as 'Update' or 'Delete' Events on selected objects associated with entries in a ListBox or Table control say; if you register the listIndex or table row as the event tag in the beginNotification call, then in your userNotify method you can use that to quickly identify the list entry or table row that needs refreshing (or removing).

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Use of Notification eventTag

Postby ConvertFromOldNGs » Fri Aug 07, 2009 11:55 am

by Craig Shearer >> Wed, 14 Jun 2000 22:26:18 GMT

I usually use the eventTag parameter with all my notification subscriptions, just out of habit. It usually turns out to be more convenient anyway, otherwise you are left to test both the eventType and theObject parameters to uniquely identify the particular notification received in the case where you have subscribed to multiple notifications.

However, it is most useful when receiving notifications from different objects each of which will be processed in the same way.

For example, you might have a Tree View control containing hetrogeneous items, and register notifications on each of the classes. For each class's delete notification, you might register the same eventTag, meaning that for any deletions of objects, they will be handled in the same manner.

You might also find it useful when handling deleted object notifications. If you receive a notification for a deleted object, then you CAN'T do the following:

if theObject.isKindOf(SomeClass) then
// handle deletion of a SomeClass object...

as theObject has been deleted, you can't call a method on it! Therefore, in these situations, the eventTag parameter can identify the type of object.

John's Timer example is also good. You might have several timers with differing periods, but you only have one timerEvent method. Therefore, the eventTag parameter is essential to identify which timer has fired.

HTH
Craig.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Use of Notification eventTag

Postby ConvertFromOldNGs » Fri Aug 07, 2009 11:55 am

by Krull >> Wed, 14 Jun 2000 23:30:01 GMT
You might also find it useful when handling deleted object notifications. If you receive a notification for a deleted object, then you CAN'T do the following:

if theObject.isKindOf(SomeClass) then
// handle deletion of a SomeClass object...

An alternative to the above, which avoids touching 'theObject' is:

SomeClass.hasInstance(theObject)

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Use of Notification eventTag

Postby ConvertFromOldNGs » Fri Aug 07, 2009 11:55 am

by JADE Kid - Ray Hidayat >> Fri, 16 Jun 2000 6:32:12 GMT

Up to now, I have always set the eventTag property the same as the eventType... but I found what was wrong with it.
I had a class which I wanted to monitor certain instances in.
And because the eventType was always the same, it was useful to put some sort of better information in eventTag.

--
Ray Hidayat
JADE Kid - 2000
www.jadekids.com


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 12 guests