That’s basically the.

Deuman: People end up doing it with threads because NIO is too new/too unknown/too horrible/all of the left.

Grunin: Tcsc, i still don’t think i udnerstand promises

Sidorowicz: Should I look into a library or just go with an es6 tut

Harju: Tfw code so bad it kill everyone who look at it

Cerventez: Now i can’t look at it

Ornelaz: Games: dunno. dash did a good job of explaining it. you’re basically pipelining values. i think the bluebird docs did a good enough job of explaining it for me when i used them first.

Beltz: Ok so promises are like piping

Ornelaz: Harju: you sort of nailed it with “But that requires me to plan my programming around that. Ugh”. promises alleviate that but don’t eliminate it.

Dunshie: What is a promise? does it bind a method to the current object with a fiber waiting for a return value?

Arcuri: Games: it’s an observer.

Ornelaz: Its an object with a then method, taking a function, that it calls when it has its value

Ornelaz: And also it has a catch method for errors

Ornelaz: And everything else is just helpers for that.

Gull: It’s an object that represents a value that might not be available yet. It keeps an array of callbacks that it calls when the value is available

Kobernick: So rudimentary-version, whendone return function thennextFunction ?

Gull: Var p = getSomeValueFromNetwork; . var p2 = p.thenfunction x { return x * 2; }; . p2.thenfunction x { console.logx; };

Larason: Gull, that makes perfect sense

Chappelle: The use makes perfect sense, i think i was thinking about the implementation

Odham: I’m guessing like a this.extend operation is happening

Gull: So you can build a pipeline of sorts, transforming values even when they’re not yet available

Heidenreich: Gull, oh by the way, i didn’t mean that I didn’t need that explanation. i mean that your explanation was what it took for me to completely understand how to use it

Gull: Games: a sketch of a simple promise-like thing: var p = {value: null, done: false, callbacks: , then: function cb { if this.done { cbthis.value; } else { this.callbacks.pushcb; }}; var req = startRequest.; req.onfinish = function result { p.value = result; p.done = true; p.callbacks.forEachfunction cb { cbresult; }; }; return p;

Gotshall: So Gull something like new Promise is just a wrapper for a similar object to what you described?

Gull: The details of the real thing are quite different, but that should give you an idea

Leverson: Games, a promise is basically an abstraction of continuations with error handling

Leverson: And some internal state

Dahley: But obviously there’s something in a callback that has to ‘escape’ javascript, doesn’t it?

Leverson: Games, not sure what you mean

Crace: I mean ultimately the only thing that can spawn processes or threads is not javascript

Santibanez: So how does a promise work in pure js

Leverson: Games, why? yes it can be pure JS

Leverson: SetTimeout is pure JS

Leverson: CPS is not just for async code

Gull: Games: the external part there is startRequest/onfinish

Leverson: And promises can wrap sync code just fine

Dotstry: Gull, how is that implemented?

Depasse: CPS being what Leverson ?

Leverson: Games, continuation p***ing style, like nested callbacks

Gull: Games: see

Endres: Hi פלאפל and Waimea.

Mauer: CPS vs. Promises, or are promises another style name

Boness: Hola senorita Gilgameshkun

Leverson: Fa, e, x = e ? erre : gx, e, y = e ? erre : hy === fa.theng.thenh.catcherr

Leverson: That’s basically the difference