How to use the es6-promise.Promise._setScheduler function in es6-promise

To help you get started, we’ve selected a few es6-promise examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github angular / zone.js / lib / microtask.ts View on Github external
global.navigator.userAgent.toLowerCase().indexOf('firefox') > -1;

var resolvedPromise;

// TODO(vicb): remove '!isFirefox' when the bug gets fixed:
// https://bugzilla.mozilla.org/show_bug.cgi?id=1162013
if (hasNativePromise && !isFirefox) {
  // When available use a native Promise to schedule microtasks.
  // When not available, es6-promise fallback will be used
  resolvedPromise = Promise.resolve();
}

var es6Promise = require('es6-promise').Promise;

if (resolvedPromise) {
  es6Promise._setScheduler(function(fn) {
    resolvedPromise.then(fn);
  });
}

// es6-promise asap should schedule microtasks via zone.scheduleMicrotask so that any
// user defined hooks are triggered
es6Promise._setAsap(function(fn, arg) {
  global.zone.scheduleMicrotask(function() {
    fn(arg);
  });
});

// The default implementation of scheduleMicrotask use the original es6-promise implementation
// to schedule a microtask
function scheduleMicrotask(fn) {
  es6Promise._asap(this.bind(fn));
github FabianGosebrink / ASPNETCore-Angular-SignalR-Typescript / src / AspNetCoreAngular2 / wwwroot / js / angular2-polyfills.js View on Github external
global.navigator.userAgent.toLowerCase().indexOf('firefox') > -1;

var resolvedPromise;

// TODO(vicb): remove '!isFirefox' when the bug gets fixed:
// https://bugzilla.mozilla.org/show_bug.cgi?id=1162013
if (hasNativePromise && !isFirefox) {
  // When available use a native Promise to schedule microtasks.
  // When not available, es6-promise fallback will be used
  resolvedPromise = Promise.resolve();
}

var es6Promise = require('es6-promise').Promise;

if (resolvedPromise) {
  es6Promise._setScheduler(function(fn) {
    resolvedPromise.then(fn);
  });
}

// es6-promise asap should schedule microtasks via zone.scheduleMicrotask so that any
// user defined hooks are triggered
es6Promise._setAsap(function(fn, arg) {
  global.zone.scheduleMicrotask(function() {
    fn(arg);
  });
});

// The default implementation of scheduleMicrotask use the original es6-promise implementation
// to schedule a microtask
function scheduleMicrotask(fn) {
  es6Promise._asap(this.bind(fn));
github angular / zone.js / dist / zone-microtask.js View on Github external
global.navigator.userAgent.toLowerCase().indexOf('firefox') > -1;

var resolvedPromise;

// TODO(vicb): remove '!isFirefox' when the bug gets fixed:
// https://bugzilla.mozilla.org/show_bug.cgi?id=1162013
if (hasNativePromise && !isFirefox) {
  // When available use a native Promise to schedule microtasks.
  // When not available, es6-promise fallback will be used
  resolvedPromise = Promise.resolve();
}

var es6Promise = require('es6-promise').Promise;

if (resolvedPromise) {
  es6Promise._setScheduler(function(fn) {
    resolvedPromise.then(fn);
  });
}

// es6-promise asap should schedule microtasks via zone.scheduleMicrotask so that any
// user defined hooks are triggered
es6Promise._setAsap(function(fn, arg) {
  global.zone.scheduleMicrotask(function() {
    fn(arg);
  });
});

// The default implementation of scheduleMicrotask use the original es6-promise implementation
// to schedule a microtask
function scheduleMicrotask(fn) {
  es6Promise._asap(this.bind(fn));