3 ms·
Does anyone know to what extend the new yield operator replaces the need for promises? Can it be used for most of promises' purposes or do the latters have thei
by chenglou 13y ago
Does anyone know to what extend the new yield operator replaces the need for promises? Can it be used for most of promises' purposes or do the latters have their particularly nice use cases? It's still confusing after a while.
- blueveek 13y agoPromises and generators actually work magnificently well together. I would recomend taking a look at an implementation of Task.js [1] [2] and, for example, some of its (increasing) usage across the Mozilla codebase [3]. [1] https://github.com/mozilla/mozilla-central/blob/master/toolkit/modules/Task.jsm https://github.com/mozilla/mozilla-central/blob/master/toolk... [2] https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/Task.jsm https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_... [3] http://dxr.mozilla.org/mozilla-central/search?tree=mozilla-central&q=Task.spawn&redirect=true http://dxr.mozilla.org/mozilla-central/search?tree=mozilla-c...