ecmascript-2017 Questions
17
Solved
I have been going over async/await and after going over several articles, I decided to test things myself. However, I can't seem to wrap my head around why this does not work:
async function main()...
Deflagrate asked 1/10, 2017 at 18:55
6
Solved
Await is a amazing feature in es7.
However,everytime I use await I found that I have to define a async function and call this function.
Such as
async function asy(){
const [resCityGuess,resCit...
Cirillo asked 7/5, 2017 at 14:9
5
Solved
I successfully check user's authentication state with onAuthStateChange observer and redirect user to the Dashboard page (react-native project). However, on the dashboard I already want to show som...
Yoshida asked 6/5, 2017 at 15:0
10
Solved
Given the following code:
var arr = [1,2,3,4,5];
var results: number[] = await arr.map(async (item): Promise<number> => {
await callAsynchronousOperation(item);
return item + 1;
});
...
Arboriculture asked 19/10, 2016 at 19:39
4
Solved
Following
How to use async/await with axios in react
I am trying to make a simple get request to my server using Async/Await in a React.js App.
The server loads a simple JSON at /data which loo...
Logan asked 13/10, 2017 at 15:33
34
Solved
Are there any issues with using async/await in a forEach loop? I'm trying to loop through an array of files and await on the contents of each file.
import fs from 'fs-promise'
async function print...
Trondheim asked 1/6, 2016 at 18:55
5
Solved
I'm trying async/await functionality. I have such code imitating a request:
const getJSON = async () => {
const request = () => new Promise((resolve, reject) => (
setTimeout(() => re...
Dentalium asked 15/4, 2017 at 6:22
19
Solved
I am trying to use the new async features and I hope solving my problem will help others in the future. This is my code which is working:
async function asyncGenerator() {
// other code
while (...
Osswald asked 22/10, 2015 at 20:4
6
Solved
I'm trying to learn async-await. In this code -
const myFun = () => {
let state = false;
setTimeout(() => {state = true}, 2000);
return new Promise((resolve, reject) => {
setTimeou...
Turco asked 25/8, 2017 at 7:39
5
Solved
In an async function, I can get an asynchronous value like so:
const foo = await myAsyncFunction()
If I want to call a method on the result, with a sync function I'd do something like myAsyncFunc...
Condemnatory asked 28/7, 2016 at 19:3
6
Solved
When using a simple callback such as in the example below:
test() {
api.on( 'someEvent', function( response ) {
return response;
});
}
How can the function be changed to use async / await? Sp...
Stereo asked 8/5, 2016 at 19:56
8
Solved
How can I reject a promise that returned by an async/await function?
e.g. Originally:
foo(id: string): Promise<A> {
return new Promise((resolve, reject) => {
someAsyncPromise().then((val...
Unbend asked 25/2, 2017 at 8:20
3
Solved
One can await a non-Promise and that's good so.
All these expressions are valid and cause no error:
await 5
await 'A'
await {}
await null
await undefined
Is there any detectable effect of awai...
Mafia asked 20/3, 2019 at 14:19
7
Solved
In https://stackoverflow.com/a/18658613/779159 is an example of how to calculate the md5 of a file using the built-in crypto library and streams.
var fs = require('fs');
var crypto = require('cryp...
Stockinet asked 8/11, 2015 at 22:20
6
Solved
I like the flatness of the new Async/Await feature available in Typescript, etc. However, I'm not sure I like the fact that I have to declare the variable I'm awaiting on the outside of a try...cat...
Parsons asked 20/6, 2017 at 22:15
6
Solved
So i'm using express.js and looking into using async/await with node 7. Is there a way that I can still catch errors but get rid of the try/catch block? Perhaps a function wrapper? I'm not sure how...
Ullyot asked 27/12, 2016 at 17:14
3
Solved
I'm working on an ng2 implementation. I'm using the following function call to convert an object to an array:
var authors = Object.entries(responseObject.Authors);
This is a standard js function. ...
Merissa asked 31/7, 2017 at 18:8
3
I have the following very basic code which is part of a more complex problem.
My problem here is the function: context.decodeAudioData(arrayBuffer) is not working on iPhone (tried on Safari and Ch...
Isadoraisadore asked 25/9, 2018 at 2:33
5
action.js
export function getLoginStatus() {
return async(dispatch) => {
let token = await getOAuthToken();
let success = await verifyToken(token);
if (success == true) {
dispatch(loginSta...
Cindy asked 30/1, 2017 at 6:56
6
Solved
I'm getting compile time error in this code:
const someFunction = async (myArray) => {
return myArray.map(myValue => {
return {
id: "my_id",
myValue: await service.getByValue(my...
Enyedy asked 27/2, 2017 at 15:46
4
Solved
I have two async functions. Both of them are waiting for two 3 seconds function calls. But the second one is faster than the first. I think the faster one is running in parallel and other in serial...
Hayrick asked 3/8, 2017 at 8:52
10
Solved
I'm digging into the node 7 async/await feature and keep stumbling across code like this
function getQuote() {
let quote = "Lorem ipsum dolor sit amet, consectetur adipiscing elit laborum.";
...
Approval asked 30/11, 2016 at 9:6
5
Solved
I have been playing around with the feature in an SPA using TypeScript and native Promises, and I notice that even if I refactor a long-running function into an async function returning a promise, ...
Koto asked 13/3, 2017 at 21:26
4
Solved
I'm new in ES7
I want to use async/await in Vue.js
Here is my code
created (){
this.getA()
console.log(2)
this.getB()
},
methods : {
getA (){
console.log(1)
},
getB (){
console.log(3)
...
Convulsion asked 2/3, 2019 at 5:10
2
Solved
I haven't seen these constructs used much but I've found myself writing them to make use of async / await in functions that wouldn't typically return a promise, for example
chan.consume(queue, (ms...
Prosthesis asked 22/11, 2016 at 15:0
1 Next >
© 2022 - 2024 — McMap. All rights reserved.