Skip to content

Instantly share code, notes, and snippets.

@dherman
Created August 27, 2015 18:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dherman/92c03e5a87e9a8ad606e to your computer and use it in GitHub Desktop.
Save dherman/92c03e5a87e9a8ad606e to your computer and use it in GitHub Desktop.
Promise.prototype.resolve = function() {
let loader = new Reflect.Loader();
let self = this;
loader[Reflect.Loader.resolve] = () => "whatevs";
loader[Reflect.Loader.fetch] = function(whatevs) {
return self;
};
return function(v) {
loader.load("whatevs"); // causes the loader to block on this promise for @@fetch
loader.provide(v); // causes the loader to resolve this promise
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment