I have something like the following:
getUser("foo").then(handleSuccess, handleError).always(tidyUp);
getUser
returns a jQuery Deferred object.
I understand from this article that I can convert the Deferred object to a native Promise using Promise.resolve
, so I can write
Promise.resolve(getUser("foo"))
.then(handleSuccess)
.catch(handleError)
The Promise API doesn't offer an always
method though, so I'm wondering how that should be handled.
Is it as follows?
Promise.resolve(getUser("foo"))
.then(handleSuccess)
.then(tidyUp)
.catch(handleError)
.then(tidyUp)