This is now an actual repo:
/* jQuery Tiny Pub/Sub - v0.7 - 10/27/2011 | |
* http://benalman.com/ | |
* Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT, GPL */ | |
(function($) { | |
var o = $({}); | |
$.subscribe = function() { | |
o.on.apply(o, arguments); | |
}; | |
$.unsubscribe = function() { | |
o.off.apply(o, arguments); | |
}; | |
$.publish = function() { | |
o.trigger.apply(o, arguments); | |
}; | |
}(jQuery)); |
/* jQuery Tiny Pub/Sub - v0.7 - 10/27/2011 | |
* http://benalman.com/ | |
* Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT, GPL */ | |
(function(a){var b=a({});a.subscribe=function(){b.on.apply(b,arguments)},a.unsubscribe=function(){b.off.apply(b,arguments)},a.publish=function(){b.trigger.apply(b,arguments)}})(jQuery) |
@gmanish var o = $({})
simply creates a jQuery collection with an empty object {}
that becomes the recipient of all the event triggers. As other comments show, the recipient could be anything like $('<b />')
.
I am telling you this is working really good.
Made a Typescript version of this here: https://gist.github.com/ahmed-musallam/d12a71b8a3ec8cebf52c12f81f3da154
I suppose I should pose that issue on a Zepto forum, but I thought someone might have a workaround here. awnings near me Toms River NJ
Zepto only makes use of the DOM-based event system so there's no way to get a real empty element to work as the global pub/sub-object. We might as well use ("").
Joana | peeling wallpaper
Thank you very much for your sharing, it has helped me in my great work, I have reduced my working time a lot because of you. I have coded some games like quordle , temple run .. if you are interested please connect with me.
Very elegant and clean code! Good job Ben! I've been using it personally at both my fun projects over at Taylordle and also Quordle game
I strongly believe that react is the way to go, especially when you are planning on having 1M+ visitors per day. A clear example is Wordle.gg which is a wordle game site and they are built using React
I will try that code. Thank you. https://cincinnati-seo.com/
Can someone help please with a TypeScript version? I'm trying to implement it on nyt crossword answers
The coding was complicated but thank you for sharing it with us. I would even share this with my friend working at Snow Removal Kamloops.
I still receive notifications about this thread even when i'm in El Paso. Any update?
code is perfect i hope to see more kleinanzeigen
I had a difficult time understanding the code. I'm having an headache. If interested, please visit our website.
In just three easy steps, Balena Etcher promises to burn operating system images to SD cards and portable ffh4x apk media flawlessly.
The Aurora store was initially based on Sergei Yeriomin's Yalp store, but v3.0 krnl apk has been completely rewritten to run on all Android 5.0 devices following Material Design Rewritten.
Cool! I'll surely be coming back for the next posts from you. Rick from Residential Painters in Regina
@cowboy this gist is getting spammed
I know some javascript and little of jQuery (been playing with Ember, just for fun). I understand the
on
off
methods, but I do not understand whatvar o = $({});
does. Can anyone please explain?As always, google doesn't consider these braces and the $ in its search results.