Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
This repository was 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

@mhevery

Description

@mhevery

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions