- From: Jake Archibald <notifications@github.com>
- Date: Fri, 27 Mar 2015 09:12:03 -0700
- To: whatwg/fetch <fetch@noreply.github.com>
- Message-ID: <whatwg/fetch/issues/27/86991787@github.com>
@getify > Do both `"child1"` and `"child2"` still get printed? Or neither? Well, you get `cancel is not a function` as those are regular promises, but I'll assume you were meant to create a cancellable promise :smile:. In your example, assuming `parent.cancel()` is called prior to it resolving, neither `"child1"` and `"child2"` is logged. This makes total sense to me, let me reword your example: ```js var parent = new CancellablePromise(resolve => setTimeout(_ => resolve("Hello"), 100)); var child1 = parent.then(value => console.log(value + " world")); var child2 = parent.then(value => console.log(value + " everyone")); ``` Is parent is cancelled before resolving, and you expected something to be logged, what would the value be? > If … passing parent around to … different parts of a system … means that … one observer … can … decide … another part of the system … is prevented from knowing … what happens with parent This isn't the case in my proposal, you can add a cancel observer in the same way you observe fulfill & reject. This would allow you to stop a spinner, but not display an error message, as cancellation often isn't error worthy. > Now, what happens if instead `child1.cancel()`. Does that mean … "child2" … gets printed? "child2" does get printed. The parent has a cancellable promise child count of 1 (`child2`) so it does not cancel. --- Reply to this email directly or view it on GitHub: https://github.com/whatwg/fetch/issues/27#issuecomment-86991787
Received on Friday, 27 March 2015 16:12:26 UTC