Skip to main content


Topic: minipact 1.1b4 (Read 2661 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
minipact 1.1b4
So what started as a strict polyfill for ES6 Promise became this:


See, as defined by spec, a Promise can only be fulfilled or rejected by the code inside of it.  This makes them very difficult to use for their intended purpose of asynchronous fulfillment.  Basically you end up having to juggle two things for every single promise--the promise itself, and the callback it registers with to resolve itself.  How did I fix it?  By extending the metaphor, of course!  Now instead of just Promises...

Code: (javascript) [Select]
var pact = new mini.Pact();
var promise = pact.makePromise();
// now you give out the promise, and then later on...
pact.resolve(promise, value);

You also have Pacts!  A given Pact can only resolve promises made from it, so you can't pull dirty tricks of making up a pact to fulfill promises on others' behalf--or if you were feeling particularly nasty, rejecting them(!). That would be VERY VERY bad! :P  Attempting to do so will throw a TypeError.
  • Last Edit: May 10, 2015, 11:40:09 pm by Lord English
Sphere 5.6.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub