Multiple Event Listeners

Anyone know if this is on the plate at some point?  Something like delegates in 
..Net?

I do it now on my own using Observer and a Subscription logic inside of a very 
simple MVC, but I wonder if there is something like that coming with the new 
compiler backend, where one can have more than one event handler assigned to a 
Delphi event through subscribe/unsubcribe...

Thanks,

--
Warm Regards,

Lee
0
Lee
4/8/2010 3:54:08 PM
embarcadero.delphi.non-tech 5933 articles. 1 followers. Follow

13 Replies
1188 Views

Similar Articles

[PageSpeed] 56

> {quote:title=Lee Jenkins wrote:}{quote}
> Anyone know if this is on the plate at some point?  Something like delegates in 
> .Net?
> 
> I do it now on my own using Observer and a Subscription logic inside of a very 
> simple MVC, but I wonder if there is something like that coming with the new 
> compiler backend, where one can have more than one event handler assigned to a 
> Delphi event through subscribe/unsubcribe...
> 
> Thanks,

This isn't an issue that could be changed with a new compiler backend.  It would require a top-to-bottom rearchitecting of the entire VCL.

Right now, event handlers are stored inside components as method pointer variables.  To enable multicast events, you'd have to change them to +lists of+ method pointers, which would be a very messy undertaking that would probably break a lot of existing code.  (Imagine the Unicode transition times ten!)
0
Mason
4/8/2010 7:54:55 PM
Mason Wheeler wrote:
>> {quote:title=Lee Jenkins wrote:}{quote} Anyone know if this is on the plate
>> at some point?  Something like delegates in .Net?
>> 
>> I do it now on my own using Observer and a Subscription logic inside of a
>> very simple MVC, but I wonder if there is something like that coming with
>> the new compiler backend, where one can have more than one event handler
>> assigned to a Delphi event through subscribe/unsubcribe...
>> 
>> Thanks,
> 
> This isn't an issue that could be changed with a new compiler backend.  It
> would require a top-to-bottom rearchitecting of the entire VCL.
> 
> Right now, event handlers are stored inside components as method pointer
> variables.  To enable multicast events, you'd have to change them to +lists
> of+ method pointers, which would be a very messy undertaking that would
> probably break a lot of existing code.  (Imagine the Unicode transition times
> ten!)

Still, would be nice to have.

--
Warm Regards,

Lee
0
Lee
4/8/2010 10:55:42 PM
> Still, would be nice to have.

I think it would be fairly easy with class helpers --

Have the class helper register itself in an OnChange event, for example,
and register other event handlers to the class helper.


-- 
With regards,

Martijn Tonies
Upscene Productions
http://www.upscene.com

Download Database Workbench for Oracle, MS SQL Server, Sybase SQL
Anywhere, MySQL, InterBase, NexusDB and Firebird!

Database questions? Check the forum:
http://www.databasedevelopmentforum.com
0
Martijn
4/9/2010 7:35:55 AM
Martijn Tonies wrote:
>> Still, would be nice to have.
> 
> I think it would be fairly easy with class helpers --
> 
> Have the class helper register itself in an OnChange event, for example,
> and register other event handlers to the class helper.
> 
> 

Hi Martijn,

I have couple of solutions that I am already using, but that sounds interesting. 
  I've not used class helpers yet!

I was just expressing that it would be nice if there was native support in 
Delphi for multiple event subscriptions though as you point out, there is always 
multiple cat skinning strategies in Delphi.

--
Warm Regards,

Lee
0
Lee
4/9/2010 11:33:49 AM
Martijn Tonies explained on 4/9/2010 :
>> Still, would be nice to have.
>
> I think it would be fairly easy with class helpers --
>
> Have the class helper register itself in an OnChange event, for example,
> and register other event handlers to the class helper.

I agree, I would have thought it could be done
without breaking any existing code.

Brad.

-- 
To people who think about their lives, almost everything
that happens, or that they read, provides a way of learning.
To those who don't examine their lives, all the experience
of the ages is worthless.
0
Brad
4/9/2010 4:35:55 PM
"Lee Jenkins" <lee@nospam.net> wrote
> ... I do it now on my own using Observer and a Subscription logic ...

Lee,  
If your Observer-Subscription logic is something like what I call 
Publisher-Subscriber logic, then I suggest that you keep using it.
If you do not like something about your implementation then you 
might be able to find a better implementation.
HTH, JohnH
0
John
4/9/2010 5:00:05 PM
John Herbster wrote:
> "Lee Jenkins" <lee@nospam.net> wrote
>> ... I do it now on my own using Observer and a Subscription logic ...
> 
> Lee,  
> If your Observer-Subscription logic is something like what I call 
> Publisher-Subscriber logic, then I suggest that you keep using it.
> If you do not like something about your implementation then you 
> might be able to find a better implementation.
> HTH, JohnH

Hi John,

Yes, I think that is what it is more commonly called.  Its patterned after 
ActionScript's AddListener approach.

Thanks again,

--
Warm Regards,

Lee
0
Lee
4/9/2010 5:24:56 PM
Hi Lee,

> Yes, I think that is what it is more commonly called.  Its patterned after
> ActionScript's AddListener approach.

Not sure if you've seen it yet but I added a multicast event framework to 
tiOPF a while back. I can't recall if I used it in other tiOPF code or just 
in our application code (I have a feeling I may have used it in the tiOPF 
logging framework or in some of the UI controls). It would be worth 
searching for. It might not be any better than your implementation but could 
give some more ideas. If you think that it is lacking then let me know too!

Regards,
Jarrod Hollingworth
0
Jarrod
4/12/2010 11:38:07 AM
On 09.04.2010 09:35, Martijn Tonies wrote:
>> Still, would be nice to have.
>
> I think it would be fairly easy with class helpers --
>
> Have the class helper register itself in an OnChange event, for example,
> and register other event handlers to the class helper.

No, that won't work.
A class helper cannot have any fields AFAIK so it won't
be able to store any lists. Only a "real" class can do that.


-- 
Arthur Hoornweg

(In order to reply per e-mail, please just remove the ".net"
  from my e-mail address. Leave the rest of the address intact
  including the "antispam" part. I had to take this measure to
  counteract unsollicited mail.)
0
Arthur
4/13/2010 6:35:07 AM
> On 09.04.2010 09:35, Martijn Tonies wrote:
>>> Still, would be nice to have.
>>
>> I think it would be fairly easy with class helpers --
>>
>> Have the class helper register itself in an OnChange event, for example,
>> and register other event handlers to the class helper.
>
> No, that won't work.
> A class helper cannot have any fields AFAIK so it won't
> be able to store any lists. Only a "real" class can do that.

Darn, good call... they allow class fields only. :-( That
could probably help but gets a bit more complicated ;-)

Well, then a special event handler class that binds itself to an
event and allows you to register multiple listeners would be
the only way, I guess.


-- 
With regards,

Martijn Tonies
Upscene Productions
http://www.upscene.com

Download Database Workbench for Oracle, MS SQL Server, Sybase SQL
Anywhere, MySQL, InterBase, NexusDB and Firebird!

Database questions? Check the forum:
http://www.databasedevelopmentforum.com
0
Martijn
4/13/2010 7:25:32 AM
Jarrod Hollingworth wrote:
> Hi Lee,
> 
>> Yes, I think that is what it is more commonly called.  Its patterned after
>> ActionScript's AddListener approach.
> 
> Not sure if you've seen it yet but I added a multicast event framework to 
> tiOPF a while back. I can't recall if I used it in other tiOPF code or just 
> in our application code (I have a feeling I may have used it in the tiOPF 
> logging framework or in some of the UI controls). It would be worth 
> searching for. It might not be any better than your implementation but could 
> give some more ideas. If you think that it is lacking then let me know too!
> 

Hi Jarrod.

The particular approach I'm using now is somewhat tied to a web framework I'm 
working on and it's a fairly simple implementation but seems to work ok.

http://leebo.dreamhosters.com/pasria/ria_base.pas
(TRiaEventManager)

That RIA framework itself, I consider very Alpha stage, but if you look at 
TRiaEventManager, you'll see its very simple implementation.  Its also pretty 
specific to the RIA framework itself.

I will dig around in tiOPF sources for your implementation.  I'm always looking 
for better ways and my implementation could always be better :-)

Heck, sometime I feel obligated to mention the Delphi community in my software 
credits!  "This software was produced by the Delphi community.  Mr. Jenkins has 
graciously offer the services of his physical body as a conduit for the 
community's knowledge"

--
Warm Regards,

Lee
0
Lee
4/13/2010 1:27:37 PM
Jolyon designed a pretty clever multitasking system, too, which he 
explained in his blog:

http://www.deltics.co.nz/blog/?p=189

I have not tried that, though, since I have written one myself a long 
time ago, and it's integrated in Prosys Sentrol, 
http://www.prosysopc.com/opc-client-server-sdk.php

I followed the naming of QT, and called the objects Signal and Slot - 
Signals send events which the Slots catch. The downside is that you need 
to define a separate object also to the listening part, but that is also 
a multi-catch one. These objects also enable automatic notifications of 
the other part being destroyed, in order to clean the references, which 
I considered very important, and this system is used heavily to connect 
components to each other.

Jouni

Lee Jenkins wrote:
> Jarrod Hollingworth wrote:
>> Hi Lee,
>>
>>> Yes, I think that is what it is more commonly called.  Its patterned after
>>> ActionScript's AddListener approach.
>> Not sure if you've seen it yet but I added a multicast event framework to 
>> tiOPF a while back. I can't recall if I used it in other tiOPF code or just 
>> in our application code (I have a feeling I may have used it in the tiOPF 
>> logging framework or in some of the UI controls). It would be worth 
>> searching for. It might not be any better than your implementation but could 
>> give some more ideas. If you think that it is lacking then let me know too!
>>
> 
> Hi Jarrod.
> 
> The particular approach I'm using now is somewhat tied to a web framework I'm 
> working on and it's a fairly simple implementation but seems to work ok.
> 
> http://leebo.dreamhosters.com/pasria/ria_base.pas
> (TRiaEventManager)
> 
> That RIA framework itself, I consider very Alpha stage, but if you look at 
> TRiaEventManager, you'll see its very simple implementation.  Its also pretty 
> specific to the RIA framework itself.
> 
> I will dig around in tiOPF sources for your implementation.  I'm always looking 
> for better ways and my implementation could always be better :-)
> 
> Heck, sometime I feel obligated to mention the Delphi community in my software 
> credits!  "This software was produced by the Delphi community.  Mr. Jenkins has 
> graciously offer the services of his physical body as a conduit for the 
> community's knowledge"
> 
> --
> Warm Regards,
> 
> Lee
0
Jouni
4/13/2010 2:37:16 PM
Jouni Aro wrote:
> Jolyon designed a pretty clever multitasking system, too, which he 
> explained in his blog:
> 
> http://www.deltics.co.nz/blog/?p=189

That was the link to the latest post - it seems there is now direct link 
to the earlier ones. If you browse back from the top links you will 
eventually find them. Here they are all:

http://www.deltics.co.nz/blog/?p=86
http://www.deltics.co.nz/blog/?p=112
http://www.deltics.co.nz/blog/?p=102
http://www.deltics.co.nz/blog/?p=147
http://www.deltics.co.nz/blog/?p=137
http://www.deltics.co.nz/blog/?p=160
0
Jouni
4/13/2010 2:42:39 PM
Reply:

Similar Artilces:

I want to add event listener for a DOM element, but I need it to listen all the event, how to do that?
// Introduced in DOM Level 2: interface EventListener { void handleEvent(in Event evt); }; My event handler is going like this: var treeCellCanvas = { // nsISupports QueryInterface: function(aIID) { if (aIID.equals(Ci.nsITreeCellCanvas) || aIID.equals(Ci.nsISupports) || aIID.equals(Ci.nsISupportsWeakReference)) return this; throw Components.results.NS_NOINTERFACE; }, handleEvent: function(event) { var x = event; }, }; But the function target.addEventListener(type, listener[, useCapture]); target.addEventLi...

Multiple NICS
We are deploying some new hardware for a relatively busy site. In a Sun e450 I have 4GB of RAM and 8 100mbit ethernet ports (two quad-port cards). It has been suggested that we can trunc several of the ports (at the OS level) and run one listener on the primary network and one listener on the back network (perhaps 6 ports primary and 2 backup). That will give me a realatively high bandwidth connection but only one network listener. The back network will be used for replication to a warm-standby and for dumps, maintenance batches, etc. I am not as worried about it's perfor...

superreview cancelled: [Bug 292464] event listeners added using addEventListener() listen only trusted events : [Attachment 182281] v.1
Smaug <smaug@welho.com> has cancelled Johnny Stenback <jst@mozilla.org>'s request for superreview: Bug 292464: event listeners added using addEventListener() listen only trusted events https://bugzilla.mozilla.org/show_bug.cgi?id=292464 Attachment 182281: v.1 https://bugzilla.mozilla.org/attachment.cgi?id=182281&action=edit ...

superreview requested: [Bug 292464] event listeners added using addEventListener() listen only trusted events : [Attachment 182281] v.1
Johnny Stenback <jst@mozilla.org> has asked Peter Van der Beken <peterv@propagandism.org> for superreview: Bug 292464: event listeners added using addEventListener() listen only trusted events https://bugzilla.mozilla.org/show_bug.cgi?id=292464 Attachment 182281: v.1 https://bugzilla.mozilla.org/attachment.cgi?id=182281&action=edit ------- Additional Comments from Johnny Stenback <jst@mozilla.org> Good catch, I'm surprised the compilers didn't whine about the mFlags problem. - In nsDocument::AddEventListener(): + nsIURI *docUri; + if ((docUri ...

superreview requested: [Bug 292464] event listeners added using addEventListener() listen only trusted events : [Attachment 182341] v1 using mDocumentURI
Smaug <smaug@welho.com> has asked Peter Van der Beken <peterv@propagandism.org> for superreview: Bug 292464: event listeners added using addEventListener() listen only trusted events https://bugzilla.mozilla.org/show_bug.cgi?id=292464 Attachment 182341: v1 using mDocumentURI https://bugzilla.mozilla.org/attachment.cgi?id=182341&action=edit ...

superreview granted: [Bug 292464] event listeners added using addEventListener() listen only trusted events : [Attachment 182341] v1 using mDocumentURI
Peter Van der Beken <peterv@propagandism.org> has granted Smaug <smaug@welho.com>'s request for superreview: Bug 292464: event listeners added using addEventListener() listen only trusted events https://bugzilla.mozilla.org/show_bug.cgi?id=292464 Attachment 182341: v1 using mDocumentURI https://bugzilla.mozilla.org/attachment.cgi?id=182341&action=edit ...

single event for multiple Event handler
hi,  I am using Linkbutton. if i Click the Linkbutton it should perform the two actions . how we should write the code for it.          Thank u in advance  If you just have 1 event handler that handler can call 2 methods which perform the actions you require. You can pass them the parameters if needed.You can also in the code behind add another reference to a function for the second event if needed.myLinButton.Click += NameOfTheMethod;I hope that helps,Brendan C. Brendan EnrickBrendan's BlogMake sure you click "Mark as Answe...

C++ Events like Delphi events
Hello everyone, This is not exactly a doubt about Delphi programming, it is more related to C++ programming, but, as I´m used to Delphi programming, I´m a little confused with some aspects of C++ Programming.. The problem that I have is with object events on C++, for example, I have the simple classes: TMyObject = class private FEvent: TNotifyEvent; procedure TriggerEvent; public OnEvent: TNotifyEvent read FOnEvent write FOnEvent; end; OK, This is a simple class that I want to use on several different places in my program, inside several differ...

multiple events modules but same event items
I would like to have a calendar page for my site. But I also want to display the next 5 events on the main page. Is there a way to have two events modules in different tabs that use the same events without having to add them twice (one for each tab)?My DNN setup on www.AxisFellowship.org Not that I know of. If you are a developer you could write your own module to access the calendar database. This could be a great feature to add to the events module, so if you do want to tackle writng a custom module to do what you need, you could put in a rquest to add this functionality. Another...

DOM objects and onfoo event listeners will no longer work in non-DOM scopes
Bug 687332 will move from storing event listeners on DOM objects such as XHR inline as member variables to storing them in the object's event listener manager. As part of this change, it will no longer be possible to set onfoo listeners in scopes that do not have a Window as their global object. This notably includes XPCOM component scopes and xpcshell tests. Setting onfoo event listeners will be silently ignored in these scopes. The correct way to do this now is to use addEventListener("foo", ...). I've fixed up all the uses I could find in mozilla-central, but ...

superreview cancelled: [Bug 292464] event listeners added using addEventListener() listen only trusted events : [Attachment 182447] Use the document's principals to check whether it's chrome or not.
Johnny Stenback <jst@mozilla.org> has cancelled Johnny Stenback <jst@mozilla.org>'s request for superreview: Bug 292464: event listeners added using addEventListener() listen only trusted events https://bugzilla.mozilla.org/show_bug.cgi?id=292464 Attachment 182447: Use the document's principals to check whether it's chrome or not. https://bugzilla.mozilla.org/attachment.cgi?id=182447&action=edit ...

superreview requested: [Bug 292464] event listeners added using addEventListener() listen only trusted events : [Attachment 182447] Use the document's principals to check whether it's chrome or not.
Johnny Stenback <jst@mozilla.org> has asked Peter Van der Beken <peterv@propagandism.org> for superreview: Bug 292464: event listeners added using addEventListener() listen only trusted events https://bugzilla.mozilla.org/show_bug.cgi?id=292464 Attachment 182447: Use the document's principals to check whether it's chrome or not. https://bugzilla.mozilla.org/attachment.cgi?id=182447&action=edit ...

superreview granted: [Bug 292464] event listeners added using addEventListener() listen only trusted events : [Attachment 182542] v2: Use the document's principals to check whether it's chrome or not
Peter Van der Beken <peterv@propagandism.org> has granted Johnny Stenback <jst@mozilla.org>'s request for superreview: Bug 292464: event listeners added using addEventListener() listen only trusted events https://bugzilla.mozilla.org/show_bug.cgi?id=292464 Attachment 182542: v2: Use the document's principals to check whether it's chrome or not. https://bugzilla.mozilla.org/attachment.cgi?id=182542&action=edit ...

superreview requested: [Bug 292464] event listeners added using addEventListener() listen only trusted events : [Attachment 182542] v2: Use the document's principals to check whether it's chrome or n
Johnny Stenback <jst@mozilla.org> has asked Peter Van der Beken <peterv@propagandism.org> for superreview: Bug 292464: event listeners added using addEventListener() listen only trusted events https://bugzilla.mozilla.org/show_bug.cgi?id=292464 Attachment 182542: v2: Use the document's principals to check whether it's chrome or not. https://bugzilla.mozilla.org/attachment.cgi?id=182542&action=edit ------- Additional Comments from Johnny Stenback <jst@mozilla.org> Yeah, duh. This should get all places in the code where this is needed. ...

Web resources about - Multiple Event Listeners - embarcadero.delphi.non-tech

New Zealand Listener - Wikipedia, the free encyclopedia
In the 1980s it lost its monopoly on the publication of upcoming television and radio programmes. Despite the increase in competition since that ...

Ghost Listener on the App Store
Read reviews, compare customer ratings, see screenshots, and learn more about Ghost Listener. Download Ghost Listener and enjoy it on your iPhone, ...


Todd Klindt's SharePoint Podcast 253 - Long Time Listener First Time Caller - YouTube
In tonight's podcast I talk a lot about Windows 10. How to install it, where to install it, ways it won't let me install it, the whole gamut. ...

Brisbane listeners desert shock jock Alan Jones show on 4BC
Brisbane radio listeners are switching off Alan Jones's breakfast show, with the latest ratings showing the shock jock commands only 5.2 per ...


Kyle Sandilands, Jackie O can't expect listeners to stay loyal
Oh, Kyle Sandilands and Jackie O, what have you done? I predict disaster at Mix 106.5.

Down Under instrumentalist blew away listeners
GREGORY NORMAN HAM MUSICIAN, SONGWRITER, ACTOR 27-9-1953 -19-4-2012 By GLENN A. BAKER GREG Ham first gained musical prominence with a striking ...

TOPICS: Shake it off, J listeners
POLL: Forget Taylor Swift for a sec. If Tay takes out No.1 in today’s Triple J Hottest 100, it won’t be the first boilover.

6PR listeners vote Jaylea's Patisserie for Perth's best pies
Listeners to 6PR Afternoons with Peter Bell have spoken - and Jaylea's Patisserie in Willagee has trumped its rivals to be named Perth's best ...

Resources last updated: 12/21/2015 5:51:46 AM