Hacker News new | ask | show | jobs
by mmastrac 5982 days ago
I did a double-take looking at that syntax. I assume that fab (and all of the other bracketed expressions) return functions that chain together? Pretty ingenious. Plus you can detect the end of the chain when one of the methods is passed in "fab" again.

I think I can say that this is the best (ab)use of the syntax I've ever seen, well done. :)

2 comments

Yeah, a (fab) function just returns itself. It's like jQuery's chaining, but using argument signatures instead of object methods to delegate work. The last (fab) is just a way to indicate the chain is over so that a listener can be returned, and has the additional benefit of making it look declarative.
Thanks for pointing that out, I've been sitting looking at how that could possibly work for a while.