Tab Atkins Jr. (2013-08-30T14:43:27.000Z)
domenic at domenicdenicola.com (2013-09-08T00:24:31.988Z)
On Fri, Aug 30, 2013 at 7:33 AM, Nathan Wall <nathan.wall at live.com> wrote: > One advantage to the `PromiseResolver` is that it's easier to pass around than two separate functions. Passing the resolver around isn't common, but at my workplace we've made use of it in a "requester" pattern. > > > function Requester() { > this.requests = Object.create(); > } > > Requester.prototype = { > respond: function(requestName, callback) { > this.requests[requestName] = callback; > }, > request: function(requestName, ...values) { > return new Promise(resolver => { > this.requests[requestName](resolver, ...values); > }); > } > }; Just change this to: this.requests[requestName]({resolve, reject}, ...values); Changing the argument signature has only a tiny, local effect on your code.