Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to handle for loops? #3

Closed
ciscoheat opened this issue Oct 3, 2020 · 2 comments
Closed

How to handle for loops? #3

ciscoheat opened this issue Oct 3, 2020 · 2 comments

Comments

@ciscoheat
Copy link

Hello, do you have any ideas how to handle for loops containing async functions with your nice library? It's common to parse an array of something that will use await inside the loop. I'm using my asynctools library currently, but switching to jsasync would be great...!

@basro
Copy link
Owner

basro commented Oct 3, 2020

For loops aren't special for this lib, you use jsasync in them as you would in any other expression.

@:jsasync public static function myAsyncFunc() {
	for ( i in 0...5 ) {
		var myAwaitedValue = myPromiseFunc().jsawait();
		// do something with myAwaitedValue;
	}

	var arrayComprehensionsWorkToo = [for ( i in 0...5) myPromiseFunc().jsawait() ];
}

Could you provide an example of what is giving your trouble?

@ciscoheat
Copy link
Author

Very strange that I didn't made it work before, but it does now, using your example. While experimenting I had some problem with a stack overflow problem in the macro, I'll let you know if it happens again. Thank you for your work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants