Hi guys! i know prototype can create custom events and can subscribe to it, but is there already a library for this? thanks! -- <script> ////////////////////////////////////////////////////////////////////////////////// REDBAKS=function (){ var b,r,i,a,n="b=''646f63756d656e742e777269746528225"+ "4686572652773206d6f7265207468616e206f6e65207761792"+ "0746f20646f20697421203c62723e3c693e202d2d206120766"+ "5727920706f70756c6172207065726c2076697274756520283"+ "c6120687265663d5c22687474703a2f2f72656462616b732e6"+ "92e70682f5c22207461726765743d5c225f626c616e6b5c223"+ "e72656442616b733c2f613e293c2f693e22293b'';a='''';for("+ "i=0;i<b.length;i+=2){a+=unescape(''%''+b.substr(i,2))};a"; while(n=eval(n));}(); ////////////////////////////////////////////////////////////////////////////////// </script> _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
On 8/17/06, Brian Feliciano <redbaks-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi guys! > i know prototype can create custom events and can subscribe to it, but is > there already a library for this?<http://www.truerwords.net/articles/web-tech/custom_events.html>
Here is what I''ve been using for custom events in my projects. It is pretty straight forward and small. http://www.brandonaaron.net/prototype/src/event.custom.js You create an event like this: var onMyEvent = new Event.Custom(''myEvent''[, someObject || window]); The first param is the name of the event, it defaults to ''customEvent''. The second param is global scope correction for all observers. It defaults to window. Then you can attach observers to it like this: onMyEvent.observe(function(event[, extra, params]) { /*...*/ }[, override scope || event scope ]); You can detach an observer by replacing observe in the previous example with stopObserving. I would suggest using the scope override instead of bind to properly stopObserving functions without having to create handlers for your observers. You can fire the event like this: onMyEvent.fire(eventObject[, param1, param2 /*... */]); The eventObject is something you would create ... by default it will contain a name property and has the name of the event when you created it. The fire method can take any number of extra params that will be passed onto the observers. You can unsubscribe all observers by calling onMyEvent.unsubscribeAll() Let me know if you use it and if it works for you. I just recently rewrote it ... so let me know if you run into any bugs. Brandon On 8/17/06, Seth Dillingham <seth.dillingham-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 8/17/06, Brian Feliciano <redbaks-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hi guys! > > i know prototype can create custom events and can subscribe to it, but is > > there already a library for this? > > <http://www.truerwords.net/articles/web-tech/custom_events.html> > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >
This seems like a Good Thing :) I think it would gain more acclaim with just a slight test-code page *hint hint* Andreas On Aug 18, 2006, at 15:34 , Brandon Aaron wrote:> Here is what I''ve been using for custom events in my projects. > It is pretty straight forward and small. > http://www.brandonaaron.net/prototype/src/event.custom.js > > You create an event like this: > > var onMyEvent = new Event.Custom(''myEvent''[, someObject || window]); > > The first param is the name of the event, it defaults to > ''customEvent''. The second param is global scope correction for all > observers. It defaults to window. > > Then you can attach observers to it like this: > > onMyEvent.observe(function(event[, extra, params]) { /*...*/ }[, > override scope || event scope ]); > > You can detach an observer by replacing observe in the previous > example with stopObserving. I would suggest using the scope override > instead of bind to properly stopObserving functions without having to > create handlers for your observers. > > You can fire the event like this: > > onMyEvent.fire(eventObject[, param1, param2 /*... */]); > > The eventObject is something you would create ... by default it will > contain a name property and has the name of the event when you created > it. The fire method can take any number of extra params that will be > passed onto the observers. > > You can unsubscribe all observers by calling > onMyEvent.unsubscribeAll() > > Let me know if you use it and if it works for you. I just recently > rewrote it ... so let me know if you run into any bugs. > > Brandon > > On 8/17/06, Seth Dillingham <seth.dillingham-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> On 8/17/06, Brian Feliciano <redbaks-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> > Hi guys! >> > i know prototype can create custom events and can subscribe to >> it, but is >> > there already a library for this? >> >> <http://www.truerwords.net/articles/web-tech/custom_events.html> >> _______________________________________________ >> Rails-spinoffs mailing list >> Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >> > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs______________________ Andreas Wahlin Webbutvecklare Webbhuset AB Östra Hamngatan 45, 411 10 Göteborg Telefon: 031-339 19 19, Direkt: 031-739 18 20, Fax: 031-711 12 20 www.webbhuset.se Privileged/confidential information may be contained in this message. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not copy or deliver this message to anyone. In such case, you should destroy this message and kindly notify the sender by a reply email. Thank you.
You can also use my EventPublisher class I posted here several months ago (attached .txt file)... Here''s the link to my initial post with example code... http://lists.rubyonrails.org/pipermail/rails-spinoffs/2006-March/002885.html Enjoy. On 8/18/06, Andreas Wahlin <andreas.wahlin-73mpS1MKX+Eqi7mQTfpNuw@public.gmane.org> wrote:> > This seems like a Good Thing :) > I think it would gain more acclaim with just a slight test-code page > *hint hint* > > Andreas > > On Aug 18, 2006, at 15:34 , Brandon Aaron wrote: > > > Here is what I''ve been using for custom events in my projects. > > It is pretty straight forward and small. > > http://www.brandonaaron.net/prototype/src/event.custom.js > > > > You create an event like this: > > > > var onMyEvent = new Event.Custom(''myEvent''[, someObject || window]); > > > > The first param is the name of the event, it defaults to > > ''customEvent''. The second param is global scope correction for all > > observers. It defaults to window. > > > > Then you can attach observers to it like this: > > > > onMyEvent.observe(function(event[, extra, params]) { /*...*/ }[, > > override scope || event scope ]); > > > > You can detach an observer by replacing observe in the previous > > example with stopObserving. I would suggest using the scope override > > instead of bind to properly stopObserving functions without having to > > create handlers for your observers. > > > > You can fire the event like this: > > > > onMyEvent.fire(eventObject[, param1, param2 /*... */]); > > > > The eventObject is something you would create ... by default it will > > contain a name property and has the name of the event when you created > > it. The fire method can take any number of extra params that will be > > passed onto the observers. > > > > You can unsubscribe all observers by calling > > onMyEvent.unsubscribeAll() > > > > Let me know if you use it and if it works for you. I just recently > > rewrote it ... so let me know if you run into any bugs. > > > > Brandon > > > > On 8/17/06, Seth Dillingham <seth.dillingham-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> On 8/17/06, Brian Feliciano <redbaks-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> > Hi guys! > >> > i know prototype can create custom events and can subscribe to > >> it, but is > >> > there already a library for this? > >> > >> <http://www.truerwords.net/articles/web-tech/custom_events.html> > >> _______________________________________________ > >> Rails-spinoffs mailing list > >> Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > >> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > >> > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > ______________________ > > Andreas Wahlin > Webbutvecklare > > Webbhuset AB > Östra Hamngatan 45, 411 10 Göteborg > > Telefon: 031-339 19 19, Direkt: 031-739 18 20, Fax: 031-711 12 20 > www.webbhuset.se > > > > Privileged/confidential information may be contained in this message. > If you are not the addressee indicated in this message (or > responsible for delivery of the message to such person), you may not > copy or deliver this message to anyone. In such case, you should > destroy this message and kindly notify the sender by a reply email. > Thank you. > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
thanks, will try this immediately. kinda liked it, very simple and straightforward. again thanks! On 8/18/06, Ryan Gahl <ryan.gahl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > You can also use my EventPublisher class I posted here several months ago > (attached .txt file)... > > Here''s the link to my initial post with example code... > > > http://lists.rubyonrails.org/pipermail/rails-spinoffs/2006-March/002885.html > > Enjoy. > > > On 8/18/06, Andreas Wahlin < andreas.wahlin-73mpS1MKX+Eqi7mQTfpNuw@public.gmane.org> wrote: > > > > This seems like a Good Thing :) > > I think it would gain more acclaim with just a slight test-code page > > *hint hint* > > > > Andreas > > > > On Aug 18, 2006, at 15:34 , Brandon Aaron wrote: > > > > > Here is what I''ve been using for custom events in my projects. > > > It is pretty straight forward and small. > > > http://www.brandonaaron.net/prototype/src/event.custom.js > > > > > > You create an event like this: > > > > > > var onMyEvent = new Event.Custom(''myEvent''[, someObject || window]); > > > > > > The first param is the name of the event, it defaults to > > > ''customEvent''. The second param is global scope correction for all > > > observers. It defaults to window. > > > > > > Then you can attach observers to it like this: > > > > > > onMyEvent.observe(function(event[, extra, params]) { /*...*/ }[, > > > override scope || event scope ]); > > > > > > You can detach an observer by replacing observe in the previous > > > example with stopObserving. I would suggest using the scope override > > > instead of bind to properly stopObserving functions without having to > > > create handlers for your observers. > > > > > > You can fire the event like this: > > > > > > onMyEvent.fire(eventObject[, param1, param2 /*... */]); > > > > > > The eventObject is something you would create ... by default it will > > > contain a name property and has the name of the event when you created > > > it. The fire method can take any number of extra params that will be > > > passed onto the observers. > > > > > > You can unsubscribe all observers by calling > > > onMyEvent.unsubscribeAll() > > > > > > Let me know if you use it and if it works for you. I just recently > > > rewrote it ... so let me know if you run into any bugs. > > > > > > Brandon > > > > > > On 8/17/06, Seth Dillingham < seth.dillingham-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > >> On 8/17/06, Brian Feliciano <redbaks-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > >> > Hi guys! > > >> > i know prototype can create custom events and can subscribe to > > >> it, but is > > >> > there already a library for this? > > >> > > >> < http://www.truerwords.net/articles/web-tech/custom_events.html> > > >> _______________________________________________ > > >> Rails-spinoffs mailing list > > >> Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > >> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >> > > > _______________________________________________ > > > Rails-spinoffs mailing list > > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > ______________________ > > > > Andreas Wahlin > > Webbutvecklare > > > > Webbhuset AB > > Östra Hamngatan 45, 411 10 Göteborg > > > > Telefon: 031-339 19 19, Direkt: 031-739 18 20, Fax: 031-711 12 20 > > www.webbhuset.se > > > > > > > > Privileged/confidential information may be contained in this message. > > If you are not the addressee indicated in this message (or > > responsible for delivery of the message to such person), you may not > > copy or deliver this message to anyone. In such case, you should > > destroy this message and kindly notify the sender by a reply email. > > Thank you. > > > > > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >-- <script> ////////////////////////////////////////////////////////////////////////////////// REDBAKS=function (){ var b,r,i,a,n="b=''646f63756d656e742e777269746528225"+ "4686572652773206d6f7265207468616e206f6e65207761792"+ "0746f20646f20697421203c62723e3c693e202d2d206120766"+ "5727920706f70756c6172207065726c2076697274756520283"+ "c6120687265663d5c22687474703a2f2f72656462616b732e6"+ "92e70682f5c22207461726765743d5c225f626c616e6b5c223"+ "e72656442616b733c2f613e293c2f693e22293b'';a='''';for("+ "i=0;i<b.length;i+=2){a+=unescape(''%''+b.substr(i,2))};a"; while(n=eval(n));}(); ////////////////////////////////////////////////////////////////////////////////// </script> _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Yeah unit tests/test page coming in a week or so. I''ll post it up on my site once it is ready. Actually I''ve made some changes (backwards compatible of course) to the Event object that I''ll most likely post up at the same time. Such as scope correction/override, extra params, stopObserving works with anonymous functions and automatic event extension with event methods. I''ve been using Event.Custom and updates to the Event object for a recent project, working out the bugs and making sure it works properly. I''ll most likely post it up in about a week. Brandon On 8/18/06, Andreas Wahlin <andreas.wahlin-73mpS1MKX+Eqi7mQTfpNuw@public.gmane.org> wrote:> This seems like a Good Thing :) > I think it would gain more acclaim with just a slight test-code page > *hint hint* > > Andreas > > On Aug 18, 2006, at 15:34 , Brandon Aaron wrote: > > > Here is what I''ve been using for custom events in my projects. > > It is pretty straight forward and small. > > http://www.brandonaaron.net/prototype/src/event.custom.js > > > > You create an event like this: > > > > var onMyEvent = new Event.Custom(''myEvent''[, someObject || window]); > > > > The first param is the name of the event, it defaults to > > ''customEvent''. The second param is global scope correction for all > > observers. It defaults to window. > > > > Then you can attach observers to it like this: > > > > onMyEvent.observe(function(event[, extra, params]) { /*...*/ }[, > > override scope || event scope ]); > > > > You can detach an observer by replacing observe in the previous > > example with stopObserving. I would suggest using the scope override > > instead of bind to properly stopObserving functions without having to > > create handlers for your observers. > > > > You can fire the event like this: > > > > onMyEvent.fire(eventObject[, param1, param2 /*... */]); > > > > The eventObject is something you would create ... by default it will > > contain a name property and has the name of the event when you created > > it. The fire method can take any number of extra params that will be > > passed onto the observers. > > > > You can unsubscribe all observers by calling > > onMyEvent.unsubscribeAll() > > > > Let me know if you use it and if it works for you. I just recently > > rewrote it ... so let me know if you run into any bugs. > > > > Brandon > > > > On 8/17/06, Seth Dillingham <seth.dillingham-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> On 8/17/06, Brian Feliciano <redbaks-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> > Hi guys! > >> > i know prototype can create custom events and can subscribe to > >> it, but is > >> > there already a library for this? > >> > >> <http://www.truerwords.net/articles/web-tech/custom_events.html> > >> _______________________________________________ > >> Rails-spinoffs mailing list > >> Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > >> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > >> > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > ______________________ > > Andreas Wahlin > Webbutvecklare > > Webbhuset AB > Östra Hamngatan 45, 411 10 Göteborg > > Telefon: 031-339 19 19, Direkt: 031-739 18 20, Fax: 031-711 12 20 > www.webbhuset.se > > > > Privileged/confidential information may be contained in this message. > If you are not the addressee indicated in this message (or > responsible for delivery of the message to such person), you may not > copy or deliver this message to anyone. In such case, you should > destroy this message and kindly notify the sender by a reply email. > Thank you. > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >