Browse Source

add haxe.coro.Continuation

Simon Krajewski 1 year ago
parent
commit
6d986dc682
2 changed files with 5 additions and 2 deletions
  1. 3 0
      std/haxe/coro/Continuation.hx
  2. 2 2
      std/haxe/coro/Coroutine.hx

+ 3 - 0
std/haxe/coro/Continuation.hx

@@ -0,0 +1,3 @@
+package haxe.coro;
+
+typedef Continuation<Result, Error> = (result:Result, error:Error) -> Void;

+ 2 - 2
std/haxe/coro/Coroutine.hx

@@ -11,12 +11,12 @@ abstract Coroutine<T:haxe.Constraints.Function> {
 		for resuming coroutine execution.
 	**/
 	@:coroutine
-	public static extern function suspend<T>(f:(cont:(T, Null<Dynamic>) -> Void)->Void):T;
+	public static extern function suspend<T>(f:(cont:Continuation<T, Null<Dynamic>>)->Void):T;
 
 	#if (jvm || eval)
 	@:native("suspend")
 	@:ifFeature("_StdTypes.Coroutine_Impl_.suspend")
-	static function nativeSuspend<T>(f, cont:(T, Null<Dynamic>) -> Void) {
+	static function nativeSuspend<T>(f, cont:Continuation<T, Null<Dynamic>>) {
 		return (_, _) -> f(cont);
 	}
 	#end