Skip to content
Turadg Aleahmad edited this page Mar 30, 2023 · 2 revisions

Rule

Use E.when(promise, onfulfilled) instead of promise.then(onfulfilled).

Explanation

E.when produces tracking info necessary for our deep stacks. .then , .catch, .finally, and await do not.

Keep in mind that the onrejected param to E.when handles only rejection of promise argument. If you want a single rejection handler like the Promise provides,

promise.then(onfulfilled).catch(onrejected)

then use the promise returned by E.when,

E.when(p, onfulfilled).catch(onrejected)
Clone this wiki locally