I'm trying to chain a series of methods that are async. I have heard of promises and futures but what I'm looking for is:
obj.setup()
.do_something()
.do_another_thing()
.end()
and not:
obj.setup()
.then(...)
.then(....)
I have come across a tutorial that explains how to do this, but unfortunately the penny hasn't dropped: http://www.dustindiaz.com/async-method-queues/ So I'm looking for a module. This module, https://github.com/FuturesJS/FuturesJS , seems to have chainify
in its API but there's no documentation on how to use it. In fact I can't find any documentation on how to use modules to achieve what I'm looking for, but plenty on using promises to get then().then().then()
which is not what I need.
Currently my module looks like:
var obj = function(){
this.async_method = function(){}
this.async_method_thingy = function(){}
this.async_method_foo = function(){}
}
var o = new obj()
var _ = {
"setup" : function(){
...
return this
},
"do_something" : function(){
o.async_method()
return this
},
"do_another_thing" : function(){
o.async_method_thingy()
return this
},
"end" : function(){
o.async_method_foo()
return this
}
}
module.exports = _
any help is appreciated ;)