Re: Re: Defer expression

2017-08-20 Thread dante federici
kai zhu has a good example of solving async order problems explicitly, as opposed to banking on any defer or timeout to figure it out. I'm a little curious of what you mean by "something that cannot run immediately". If it can't be run immediately, then there should be *something* you can hook

Re: Re: Defer expression

2017-08-19 Thread Isiah Meadows
Closer to the proposed `Promise.try`, in that it starts synchronously. Also, normal `do` expressions are stage 1 currently, and the core concept hasn't changed much in the several years of the proposal's existence. (It's based on statement completion values, like `eval`.) On Thu, Aug 17, 2017,

Re: Re: Defer expression

2017-08-18 Thread kai zhu
i can give you a specific solution to one of my async init problems (done entirely in vanilla es5 code). in this use-case, i want to run integrated tests, but have to wait for the server to listen on a port, and the db to be seeded first. to keep complexity at a manageable level, i find its

Re: Re: Defer expression

2017-08-17 Thread Matthew Robb
Yeah essentially although I'd think of it more as sugar for: (async () => { await null; ... })() On Aug 17, 2017 4:17 PM, "Tab Atkins Jr." wrote: > On Thu, Aug 17, 2017 at 12:12 PM, Matthew Robb > wrote: > > Honestly have there been any proposals

Re: Re: Defer expression

2017-08-17 Thread Tab Atkins Jr.
On Thu, Aug 17, 2017 at 12:12 PM, Matthew Robb wrote: > Honestly have there been any proposals for something like `do async { // can > await here }` which would produce a promise in the enclosing scope Do-expressions haven't advanced in general yet, but if/when they do,

Re: Re: Defer expression

2017-08-17 Thread Matthew Robb
Honestly have there been any proposals for something like `do async { // can await here }` which would produce a promise in the enclosing scope - Matthew Robb On Thu, Aug 17, 2017 at 11:27 AM, Logan Smyth wrote: > `setTimeout` it is defined in the HTML spec,

Re: Re: Defer expression

2017-08-17 Thread Logan Smyth
`setTimeout` it is defined in the HTML spec, https://www.w3.org/TR/html5/single-page.html#timers, not the ECMA spec. The ECMA spec has no concept of time-based delays at all, promise-based or otherwise. On Wed, Aug 16, 2017 at 11:03 PM, Naveen Chawla wrote: > An in built

Re: Re: Defer expression

2017-08-17 Thread Naveen Chawla
An in built `Promise` version of `setTimeout` would be cool: `Promise.delay()` and `Promise.delay(500)` On Thu, 17 Aug 2017, 7:37 a.m. kai zhu wrote: > setTimeout is still the best solution in my mind. none of the promise > or async code examples presented are as

Re: Re: Defer expression

2017-08-16 Thread kai zhu
setTimeout is still the best solution in my mind. none of the promise or async code examples presented are as immediately obvious as setTimeout that the code is to self-run at a later time (and you don't need the 1ms argument). ```js // self-comment that this code will self-run // after the main

Re: Re: Defer expression

2017-08-16 Thread Matthew Robb
I think this will actually get you what you're after: (async function () { await null; // Deferred code here })() On Aug 16, 2017 5:46 PM, "Darien Valentine" wrote: @logan ah, oops, that was an (incorrect) assumption about the proposed behavior on my part

Re: Re: Defer expression

2017-08-16 Thread Darien Valentine
@logan ah, oops, that was an (incorrect) assumption about the proposed behavior on my part ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Re: Defer expression

2017-08-16 Thread T.J. Crowder
I believe this is the most recent on this topic: https://esdiscuss.org/topic/microtask-scheduling -- T.J. Crowder ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Re: Defer expression

2017-08-16 Thread Logan Smyth
`Promise.try` calls its callback synchronously like `new Promise` does, so it would not be a substitute for this case. On Wed, Aug 16, 2017 at 1:29 PM, Darien Valentine wrote: > Deferring can mean different things, but generally `then` covers this well > (specifically,

Re: Re: Defer expression

2017-08-16 Thread Darien Valentine
Deferring can mean different things, but generally `then` covers this well (specifically, pushing execution of something to the end of the current task). Promise.resolve().then(stuffToDefer); I think there is a proposal for `Promise.try(stuffToDefer)`, which would eliminate the need for the