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

@async short lambdas not unpacked correctly? #38

Open
cambiata opened this issue May 6, 2020 · 0 comments
Open

@async short lambdas not unpacked correctly? #38

cambiata opened this issue May 6, 2020 · 0 comments

Comments

@cambiata
Copy link

cambiata commented May 6, 2020

Using tink_await 0.6.0, oldschool anonymous functions work as expected, but arrowfunctions don't - the return value isn't unpacked correctly. Noticed when trying Future.ofJsPromise as below, but the same seems to happen when using all Futures:

@await class Main {
	@async static function main() {	
		
		// This works fine:
		js.Browser.document.onmousedown = @async function(e) {
		 	var int = @await Future.ofJsPromise(testJsPromise());
		 	trace(int);	// traces 1234
		};

		// This doesn't:
		js.Browser.document.onmousedown = @async (e)-> {
			var int = @await Future.ofJsPromise(testJsPromise());
			trace(int);	// traces the promise method	
		};
	}

	static function testJsPromise():Promise<Int> {
		return new Promise<Int>((res, rej)->{
			haxe.Timer.delay(()->res(1234), 1000);
		});
	}
}
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

1 participant