intercaljs - manage callbacks and deferreds with style
you discovered $.ajax, $.Deferred and maybe $.Callbacks and started using them to handle the async world of a webapp.
after a while your ajax calls, callbacks and deferreds are all over the place and the code is a mess.
It's hard to know the kind of events your application generates and sometimes you don't have access to them from where you are.
There is no single place to go look for the list of events and deferreds.
There is no single place to go look at the URLs for the ajax requests. You change an API endpoint in the server and have to edit it in multiple places in the client since you ajax calls are scattered in the code
There is no structure or convention on them.
you need to wait for some deferreds and/or callbacks and start doing callback accounting by hand.
if so, then intercaljs is for you.
what is it?
intercaljs is a small jquery library that allows organizing your events, resources, URLs and deferreds in one place, hierarchically.
it also provides utilities to wait for a set of events/deferreds in a unified and clean way, for example:
- wait for the first event/deferred
- wait for N
- wait for all
- wait with timeout
- listen to any or all child events/deferreds from a given node in the hierarchy
git clone https://github.com/marianoguerra/intercaljs
or open test/index.html in your browser
BSD (+ optional beer to the author)