[Prototype-core] Re: Proposal: Custom Events / Messaging
:) I'm already seeing one. A LOVE doctor... On 2/8/07, Colin Mollenhour <[EMAIL PROTECTED]> wrote: > > > Dude, you should see a doctor.. > > On Feb 8, 9:06 am, "Ryan Gahl" <[EMAIL PROTECTED]> wrote: > > *cough* *cough*, EventPublisher... *cough* *cough* links provided in > this > > thread... *cough* *cough* provides everything you're looking for *cough* > > *cough* lightweight > > > > *cough* > > > > > -- Ryan Gahl Application Development Consultant Athena Group, Inc. Inquire: 1-920-955-1457 Blog: http://www.someElement.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Prototype: Core" group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Re: Proposal: Custom Events / Messaging
Dude, you should see a doctor.. On Feb 8, 9:06 am, "Ryan Gahl" <[EMAIL PROTECTED]> wrote: > *cough* *cough*, EventPublisher... *cough* *cough* links provided in this > thread... *cough* *cough* provides everything you're looking for *cough* > *cough* lightweight > > *cough* --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Prototype: Core" group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Re: Proposal: Custom Events / Messaging
*cough* *cough*, EventPublisher... *cough* *cough* links provided in this thread... *cough* *cough* provides everything you're looking for *cough* *cough* lightweight *cough* On 2/8/07, Christian Schaefer <[EMAIL PROTECTED]> wrote: > > > hi seth, > > > It's really *intended* for synthetic events, and offers an approach to > > writing applications that is entirely based on synthetic events, > > versus hard-linking of your app's various classes together. > > hmm.. I've had a more closer look to synthetic events. certainly they > can be used to achieve what I'm after. but I'm not sure I am completely > happy with the solution. > > synthetic events (like all events) have to have a target element which > for a more general class/object interaction might not be useful. > of course you can always choose any element even the window element but > i think this is not useful. especially adding elements to the dom just > to have a target at all should not be the way to go imho. if you need > your classes to interact on events/messages there should be a direct > way. an element just to carry the event is an unnecessary vehicle. > > also I really do like the api colin suggested earlier on. it allows you > to register many responders (observers) to many messages (events) in one > single and compact call. > > I think this is more useful for this general purpose because it keeps > your code clean and structured. instead of having many Event.observe() > calls you will only have one Message.Responders.register() call with all > callbacks neatly packed into its argument. this is more prototype style > I think. > (side note: it could be a good idea to have Event.observe() taking > multiple observers at once) > > of course you could extend Object to dispatch events as elements do and > directly use your class objects as event targets but then again wouldn't > this be over the top? > > > > cheers > /christian > > > > -- Ryan Gahl Application Development Consultant Athena Group, Inc. Inquire: 1-920-955-1457 Blog: http://www.someElement.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Prototype: Core" group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Re: Proposal: Custom Events / Messaging
hi seth, > It's really *intended* for synthetic events, and offers an approach to > writing applications that is entirely based on synthetic events, > versus hard-linking of your app's various classes together. hmm.. I've had a more closer look to synthetic events. certainly they can be used to achieve what I'm after. but I'm not sure I am completely happy with the solution. synthetic events (like all events) have to have a target element which for a more general class/object interaction might not be useful. of course you can always choose any element even the window element but i think this is not useful. especially adding elements to the dom just to have a target at all should not be the way to go imho. if you need your classes to interact on events/messages there should be a direct way. an element just to carry the event is an unnecessary vehicle. also I really do like the api colin suggested earlier on. it allows you to register many responders (observers) to many messages (events) in one single and compact call. I think this is more useful for this general purpose because it keeps your code clean and structured. instead of having many Event.observe() calls you will only have one Message.Responders.register() call with all callbacks neatly packed into its argument. this is more prototype style I think. (side note: it could be a good idea to have Event.observe() taking multiple observers at once) of course you could extend Object to dispatch events as elements do and directly use your class objects as event targets but then again wouldn't this be over the top? cheers /christian --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Prototype: Core" group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Re: Proposal: Custom Events / Messaging
On 2/7/07, Christian Schaefer <[EMAIL PROTECTED]> wrote: > > hi mislav, > > > See this API documentation (work by Seth Dillingham): > > http://www.truerwords.net/articles/web-tech/custom_events_ref.html > > > very interesting approach certainly. > maybe I should think about synthetic events to be part of my > implementation. but I can not but notice that the implementation by seth > is a bit too much for me. It was intended for larger projects, certainly. It's being used in a number of sites now. I used it in an aggregator, and prototyped (ahem) an email client with it. If you just need a couple of click or mouseover events, then my approach is probably too much... after all, it adds a crushing 8 KB to your page. It's really *intended* for synthetic events, and offers an approach to writing applications that is entirely based on synthetic events, versus hard-linking of your app's various classes together. Seth --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Prototype: Core" group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Re: Proposal: Custom Events / Messaging
And of course, there is always EventPublisher, which is pretty lightweight and has served me well in many projects: http://wrath.rubyonrails.org/pipermail/rails-spinoffs/2006-February/002875.html Short usage description: http://lists.rubyonrails.org/pipermail/rails-spinoffs/2006-March/002885.html For a global event dispatcher, just create an instance of EventPublisher at the global scope level... var myEventDispatcher = new EventPublisher(); On 2/7/07, Christian Schaefer <[EMAIL PROTECTED]> wrote: > > > hi mislav, > > > See this API documentation (work by Seth Dillingham): > > http://www.truerwords.net/articles/web-tech/custom_events_ref.html > > > very interesting approach certainly. > maybe I should think about synthetic events to be part of my > implementation. but I can not but notice that the implementation by seth > is a bit too much for me. > > I do like the synthetic event approach but the api he created appears > far too complicated to me. I mean you have to create publisher objects > just to fire an event rather than just make a function call to send a > message. I like colins suggestion of using an api similar to > Ajax.Responders far better for its simplicity. > > > what do you think? > > > cheers > /christian > > > > -- Ryan Gahl Application Development Consultant Athena Group, Inc. Inquire: 1-920-955-1457 Blog: http://www.someElement.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Prototype: Core" group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Re: Proposal: Custom Events / Messaging
hi mislav, > See this API documentation (work by Seth Dillingham): > http://www.truerwords.net/articles/web-tech/custom_events_ref.html very interesting approach certainly. maybe I should think about synthetic events to be part of my implementation. but I can not but notice that the implementation by seth is a bit too much for me. I do like the synthetic event approach but the api he created appears far too complicated to me. I mean you have to create publisher objects just to fire an event rather than just make a function call to send a message. I like colins suggestion of using an api similar to Ajax.Responders far better for its simplicity. what do you think? cheers /christian --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Prototype: Core" group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Re: Proposal: Custom Events / Messaging
Hello all, See this API documentation (work by Seth Dillingham): http://www.truerwords.net/articles/web-tech/custom_events_ref.html -m --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Prototype: Core" group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Re: Proposal: Custom Events / Messaging
Colin Mollenhour wrote: > I just thought of a possible problem with the API I proposed.. As > anyone who joined a large mailing list before knows, a great number of > people cannot properly spell "unsubscribe". They would be stumped as > to why their "Topic.unsuscribe" calls are causing errors... haha, very good point indeed. I therefor used Message.Responders.register() and Message.Responders.unregister() which should be easier to spell and is a similar syntax as in Ajax.Responders which should add to its compatibility. cheers /christian --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Prototype: Core" group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Re: Proposal: Custom Events / Messaging
I just thought of a possible problem with the API I proposed.. As anyone who joined a large mailing list before knows, a great number of people cannot properly spell "unsubscribe". They would be stumped as to why their "Topic.unsuscribe" calls are causing errors... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Prototype: Core" group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Re: Proposal: Custom Events / Messaging
Christian, I've never programmed with such "global" events, but I like the idea very much and can think of several places it could be useful in my own projects. However, I don't think adding this functionality on top of Prototype's Event is a good idea. Just like Tobias suggested to me on my Event patch, add the new functionality in it's own class since it really is different functionality altogether. This will avoid confusion with the existing Event.observe API and keep the code cleaner. I'd suggest something like "Message" or (I just looked up dojo's API) "Topic". Example API: //in the vein of Ajax.Responders, this should already be familiar to Protoype users Topic.Responders.register({ onStart: loader.onCallbackStart, onEnd: loader.onCallbackEnd }); // subscribe to an event topic Topic.subscribe('testEvent', function(){ alert('testEvent called with '+arguments.length+' arguments'); }); // publish the event to all subscribers Topic.publish('testEvent', {bar:'foo'}); Of course you can use whatever names for the class and methods you like, my point is just that this should be a separate API altogether. This will let you avoid passing null parameters, etc.. Also, I suggest that registering an event name before using it *not* be required, there is simply no need to. What do you think of my suggestions? Colin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Prototype: Core" group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Re: Proposal: Custom Events / Messaging
hi again, waiting anxiously for your reply :) I noticed that the method 'throw()' is only working in firefox but not in opera or ie (which makes sense because it's a reserved word). this can be fixed by renaming that method to 'fire()' instead. after this my code works on all browsers available to me (ie6, ie7, win/ff2, opera9) cheers /christian On Feb 5, 11:51 am, Christian Schaefer <[EMAIL PROTECTED]> wrote: > hi all, > > during developing you encounter several problems. one that frequently > occurs to me while working on rather complex user interfaces is that all > you on page modules (tag clouds, friend lists, you name it..) are to an > extend interlocked with each other. the more complex your ui gets the > more each module has to know about the others and the more hard it gets > to maintain your code. > > on most window manager systems like gnome and the like (even windows) > you have a messaging mechanism for that. objects can send out a message > (ie: 'deleted a file') and other objects can subscribe to such a message. > > this very much works like the javascript Event object and the prototype > observing. so i thought why not extend the Event object even more and > include the possibility to register new events and throw them, and > extend the methods observe() and stopObserving() to enable client > modules to observe these new custom events. > > I know that the dojo toolkit has a similar thing going. but so far dojo > didn't feel like the right tool for the job for me (no flamewars please). > > attached to this mail you can find my solution and a (admittedly very) > brief demo. some more 'documentation' is in the head comment of the > event.js file. > > I hope you agree with me that this is a simple, clean and good solution > to my problem. if you do I would very much appreciate to share this code > with the prototype community and hereby ask for the inclusion of the > attached code. > > cheers > /christian > > Custom Events - A Prototype JavaScript framework proposal.zip > 24KDownload --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Prototype: Core" group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---