- From: Brandon Wallace <brandon.wallace@yahoo.com>
- Date: Thu, 11 Apr 2013 16:49:10 -0700 (PDT)
- To: "Tab Atkins Jr." <jackalmage@gmail.com>, "www-dom@w3.org" <www-dom@w3.org>
Received on Thursday, 11 April 2013 23:49:38 UTC
It would also be nice to have something like Future.fails(x) because it is also occasionally useful to return a promise that immediately fails with a specific error. ________________________________ From: Tab Atkins Jr. <jackalmage@gmail.com> To: www-dom@w3.org Sent: Thursday, April 11, 2013 6:43 PM Subject: [futures] Add convenience functions for immediate/canceled promises Task.js has two convenience functions, now(x) and never(), which return a resolved or cancelled promise, respectively. This is useful when combining plain values with the promise algebra, so the combinators don't need to ducktype their arguments to try and guess whether they're a promise or a plain value. (Plus, it lets you easily create a promise which resolves to a promise and use it in the combinators.) Separately, there's been discussion over at the PromisesAPlus github about more explicitly supporting the fact that promises are monadic, by defining a point/pure/return function that just returns a "default" (fulfilled) promise from a base value <https://github.com/promises-aplus/resolvers-spec/issues/24>. Supporting these use-cases seem useful and simple. We should add Future.of(val) and Future.never() convenience static functions to the Future interface. ~TJ
Received on Thursday, 11 April 2013 23:49:38 UTC