Seems like an anti-pattern (and someone who works on C# made this argument to me in response to the await thread)
-
-
-
Well specifically if it *just* returns a future, what good is the intermediate future? But there are futures that return tuples of futures and other things, like select
- 4 more replies
New conversation -
-
-
Not really a Future per se, but tokio::net::TcpStream::connect() returns a Future which returns a Stream.
-
Ah yeah, that's a good one. Same in Romio https://docs.rs/romio/0.3.0-alpha.1/romio/struct.TcpStream.html#method.connect … I guess if the topic of Streams is included, there might be more examples like these.
End of conversation
New conversation -
-
-
I think fetch in the browser does this: fetch(jsonUrl) .then(function(res) { return res.json() }) .then(function(myJson) { console.log(JSON.stringify(myJson)) }) Or it can be written with async/await: JSON.stringify( await (await fetch(jsonUrl)).json() )
-
With newlines: var req = await fetch(jsonUrl) var json = await req.json() JSON.stringify(json) I guess similar situations would occur with fs operations. I guess it's different than what I imagined, tho it seems similar?
End of conversation
New conversation -
-
-
in JS you cannot return a Promise from a Promise, resolutions are "auto-flattened": Promise.resolve(Promise.resolve(1)).then(x => assert(x == 1)) new Promise(resolve => resolve(Promise.resolve(1))) .then(x => assert(x == 1))
-
Heh, didn't know that. I guess it makes sense tho.
End of conversation
New conversation -
-
-
I have tons of them. Let me check later. Ping me if I don’t.
-
Seeing the other discussion: Basically all `and_then` closures return futures (which might be leaf futures). Is that what you mean or something else?
- 2 more replies
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.