Live data from Hacker News

Google open-sources JsAction, a JavaScript event delegation library

github.com

31–40 of 48 posts

Re: Google open-sources JsAction, a JavaScript event delegation library

#31

The API could use some work. To implement the simplest example, I need to remember patterns like: > eventContract.dispatchTo(goog.bind(dispatcher.dispatch, dispatcher)); imho, there's a problem if you need to dust off your gang of four book to understand the API. Might as well include an AbstractSingletonProxyFactoryBean.

The API could certainly use some work, and it's worse than you mention. If it were just a matter of applying widely-known Gang of Four patterns it would be fine. All over the place it looks like the designer didn't realize there's a built-in Function.prototype.bind.

In IE8 and FF3.6, there isn't. If you believe netmarketshare.com, that's 20% of users right there.

Re: Google open-sources JsAction, a JavaScript event delegation library

#32
post #2

Interesting. This might have come from the Google+ development team, as this and something called "jsmodel" are part of that product. You can see traces of both of these in the DOM of plus.google.com

Actually you can also see traces of the jsaction attribute in the G+ product. G+ isn't using this from the group up though. It has a pretty long history at Google, so I'm not even sure where it came from. Should have been either Maps or Search.

It started in maps. At the time IE had some issues with memory leaks when dom elements with an event listener attached were deleted. This allowed them to have just one listener for the page.

Re: Google open-sources JsAction, a JavaScript event delegation library

#33
post #31

Earlier quoted context omitted.

The API could certainly use some work, and it's worse than you mention. If it were just a matter of applying widely-known Gang of Four patterns it would be fine. All over the place it looks like the designer didn't realize there's a built-in Function.prototype.bind.

In IE8 and FF3.6, there isn't. If you believe netmarketshare.com, that's 20% of users right there.

IIRC, lots of Google products (like Google Docs) don't support those browsers entirely.

Re: Google open-sources JsAction, a JavaScript event delegation library

#35
post #27

Earlier quoted context omitted.

Javascript, in a browser, exists to manipulate the document. If your opinion is that decoupling the elements of that document from the actions that might happen as a result of interacting with that element then so be it, but I couldn't disagree more. Even if it allows them to live in a "nicer" language (JS vs HTML), I'd rather everything be declared up front. Reading someone else's Backbone code (as compared to Angul…

> I'd rather everything be declared up front. I'm all for declaring up front, just not in html. > Reading someone else's Backbone code (as compared to Angular or Ember) is really, really not fun for me. Backbone is far from what I consider good readability. If encourages bad habits by not providing templating and sort of encouraging use of jQuery for dom modification. Binding events to backbone view is what I conside…

Finally, we can both agree that jquery dom manipulation is a great way to find yourself in a mess of unmaintainable code.

If you're a fan of backbone views though - why not React? IMO it's very similar to backbone but with sane structure and an incredibly powerful render loop.

Re: Google open-sources JsAction, a JavaScript event delegation library

#36

So this (with specialized lib, and fairly large unintuitive js code to set whole thing up): is pretty much the same as this: without any abusing or manipulating of html and dom and with setup as simple and understandable as this: window.Actions = { leftNav: { clickAction: function() { myApp.LeftNav.doSomeSeriousStuff(); }, doubleClickAction: function() { // very late loading of implementation require("LeftNavActions"…

I like the syntax, but it bugs me that the behaviour goes into the HTML. I really like keeping my event mapping in the javascript so I keep a clean separation between structure in the HTML and behaviour in the JS.

Re: Google open-sources JsAction, a JavaScript event delegation library

#37

This seems pretty complicated and not so simple. Someone else asked, "How is this better than Backbone?" Backbone is (a lot) more than just an event lib. A better question would be, "How is this better than OnOff?" (which is basically the equivalent of the events part of Backbone): https://github.com/LiftoffSoftware/OnOff

How is OnOff better than just the standard EventEmitter?

Re: Google open-sources JsAction, a JavaScript event delegation library

#38
post #6

I like they are putting this on Github instead of (or on top of) Google Code

Google code could have been great.But the UX sucks so much and has never been updated.

Github is successfull because of git AND its good clean UX.

Google code feels like developpers were in charge of the UX. It's a UX disaster and will be retired sooner or later.

Re: Google open-sources JsAction, a JavaScript event delegation library

#40

So this (with specialized lib, and fairly large unintuitive js code to set whole thing up): is pretty much the same as this: without any abusing or manipulating of html and dom and with setup as simple and understandable as this: window.Actions = { leftNav: { clickAction: function() { myApp.LeftNav.doSomeSeriousStuff(); }, doubleClickAction: function() { // very late loading of implementation require("LeftNavActions"…

I like the syntax, but it bugs me that the behaviour goes into the HTML. I really like keeping my event mapping in the javascript so I keep a clean separation between structure in the HTML and behaviour in the JS.

I don't know. I think the one of the best things about Angular for example is that you often see straight away what's happening because of it's declarative nature. With normal event handlers you don't know what's going on until you specifically search for the id/class/tag in all the JS files.
Post reply on HN