cowboy / jquery-tiny-pubsub Goto Github PK
View Code? Open in Web Editor NEWA really, really, REALLY tiny pub/sub implementation for jQuery.
License: MIT License
A really, really, REALLY tiny pub/sub implementation for jQuery.
License: MIT License
[Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive. See https://www.chromestatus.com/features/6662647093133312
(anonymous) @ scripts.unified.js?ver=4.5.1:50
Hi,
thanks a lot for awesome pub-sub implementation!
Not sure if it's bug, or if I'm missing something, so let's call this issue a question first. Readme states:
... In addition, should you need it, these methods are fully compatible with the jQuery.proxy() method, in case you not only want more control over to which context the subscribed callback is bound, but want to be able to very easily unsubscribe via callback reference. ...
However, I don't think it does or don't understand how I could bind custom context to subscribed callback. Because it always falls back to the main o
object: o.trigger.apply(o, arguments);
Could you please add example of $.proxy
usage into readme in the case it's really possible?
Have a nice day,
Luk
PS: Perhaps you mean it is compatible with jQuery.proxy when supplying the callback: $.subscribe('foo', $.proxy(createLogger, $someContext, 'foo'));
?
`
Any chance on registering this repo in bower?
Just stumbled on this and noticed it's almost identical to something I've written before (like, a few characters away). Seems a bit backwards to have a license on something that is both obvious and reproducible within a minute. Plus the license is way longer than the code itself! Let it free, no?
Hi,
I was looking for a simple Pub/Sub system to use with jQuery/jQuery UI and I found "jquery-tiny-pubsub", which is great. However, I don't really like that the functions are called with an event object as first argument.
In your example, you say : "// Skip the first argument (event object) but log the name and other args.".
$.publish("msg", 5);
$.widget('myWidget', {
_create: function () {
var self = this;
$.subscribe("msg", $.proxy(self, "_handleRecieve"));
},
_handleRecieve: function (event, value) {
this.element.append("<p>" + value + "</p>");
}
});
I don't want the signature of the "_handleRecieve" method to be "function (event, value) ", but "function (value)", because the "event" it's never used.
Therefore, I rewrote the method "subscribe" as I follows:
$.subscribe = function() {
var events, handler, handlerWrapper;
events = arguments[0];
handler = arguments[1];
handlerWrapper = function(event) {
return handler.apply(this, Array.prototype.slice.call(arguments, 1));
};
o.on.call(o, events, handlerWrapper);
};
I would like to know your oppinion on this implementation. Are there any downsides?
Why not add someone as a contributor to this so it can be updated :)
The current README.md states the wrong links to the raw production and development files.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.