co
co copied to clipboard
choose Promise which you like
if we don't like to use native Promise, we can choose other Promises, such as bluebird.
co.set(require('bluebird'));
co(1).tap(console.log);
by using it ,we can use the tap function of Promise
update on 2017/2/21
co.promise = require('bluebird');
co(1).tap(console.log);
Are the any solid reasons of using generators along with non-native Promises?
Personnaly I would like to have this option. And about the why :
- performance (native promise are slow)
- avoid the pattern bluebird.resolve(co.wrap(...)) if you need some helper from bluebird for example
And I can't see any reason why not ?
@jeanbaptiste-brasselet-planorama yes, this absolutely makes sense.
@jeanbaptiste-brasselet-planorama I agree with you. But I just consider the second point.
As I said above, if I want to use some functions with bluebird, such as co(1).tap(console.log);, I hava to use bluebird.resolve(co.(...)). It is a fact that your ability to express a lot better than I do.
yeah it should be
Of course this is a valuable feature! +1