Deferred - A TypeScript Promise wrapper

Sep 18, 2016

I love Promises,
and I love that they’re becoming a core Javascript feature. However, the
standard implementation doesn’t let you query the
state or fate
of a promise, which in some cases may be necessary.

While working on the Vevida Aurelia datagrid,
I found I needed to know whether a given promise had been fulfilled yet. I wrote
this TypeScript wrapper class, and named it ‘Deferred’ after Angular’s
Deferred API,
which they in turn based on the Q library.