Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Create bindPromiseFn which converts a non native Promise to Native Promise #49

Closed
mhevery opened this issue Feb 20, 2015 · 0 comments
Closed

Comments

@mhevery
Copy link
Contributor

mhevery commented Feb 20, 2015

Similar to bind() have a method which would allow us to easily capture zone on methods which instead of taking callbacks return Promise

function bindPromiseFn(delegate) {
  return function() {
    var delagtePromise = delegate.apply(this, arguments);
    if (deletaePromise instanceof Promise) {
      return delegatePromise;
    } else {
      return new Promise(function(resolve, reject) { 
        delegatePromise.then(resolve, reject); 
      });
    }
 };
}

See the workaround I had to do to fix an issue: https://github.com/rkirov/youtube-app/pull/1/files

@mhevery mhevery changed the title Create bindPromiseFn Create bindPromiseFn which converts a non native Promise to Native Promise Feb 20, 2015
@btford btford closed this as completed in 643f2ac Feb 20, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants