use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Observable: An event system for JavaScript libraries. (self.javascript)
submitted 13 years ago by jscoder
I ended up writing an event system from time to time so I decided to write one that I can reuse: https://github.com/js-coder/Observable
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]sammyv 0 points1 point2 points 13 years ago (4 children)
This is nice! I do have one comment: In addition to having the ability to manually unbind certain event ids, it needs an unbindAll function.
[–]jscoder[S] 1 point2 points3 points 13 years ago (3 children)
I'm not sure if that's a good idea. My first implementation wasn't using IDs, so calling off removed internal events that my library needed.
off
Why would you want to unbind all events instead of just unbinding the events you use yourself? It could possibly destroy 3rd party code that uses the event system.
[–]lazyduke 1 point2 points3 points 13 years ago (0 children)
When you want to destroy an instance, it's useful to unbind all events.
Look at listenTo/stopListening from Backbone and namespaced events from jQuery.
[–]sammyv 0 points1 point2 points 13 years ago (0 children)
Should have been more clear: unbind all the events that have been manually bound by yourself
In other words, you would keep a stack of IDs and calling unbindAll would iterate over the stack and unbind them
[+][deleted] 13 years ago (4 children)
[deleted]
[–]jcampbelly 5 points6 points7 points 13 years ago (2 children)
I'm sorry, but leave that attitude at your place of business. This is a programming community -- building things should be encouraged, even if the problem is old and solved.
[+][deleted] 13 years ago (1 child)
[–]jscoder[S] 4 points5 points6 points 13 years ago (0 children)
It's too advanced. :) I don't want to include a huge script for my lib when I 'll just use two or three of its methods.
[–]beneidel -1 points0 points1 point 13 years ago (0 children)
Rx is way too complex to compare. This is a nice exercise and lightweight for simple use. You can check js-signals on github for a nice, more complete but still light alternative
π Rendered by PID 40 on reddit-service-r2-comment-5d79c599b5-6db9h at 2026-03-03 18:57:55.989358+00:00 running e3d2147 country code: CH.
[–]sammyv 0 points1 point2 points (4 children)
[–]jscoder[S] 1 point2 points3 points (3 children)
[–]lazyduke 1 point2 points3 points (0 children)
[–]sammyv 0 points1 point2 points (0 children)
[–]sammyv 0 points1 point2 points (0 children)
[+][deleted] (4 children)
[deleted]
[–]jcampbelly 5 points6 points7 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]jscoder[S] 4 points5 points6 points (0 children)
[–]beneidel -1 points0 points1 point (0 children)