mirror of
https://github.com/fluencelabs/aqua.git
synced 2024-12-04 22:50:18 +00:00
resolve promise instantly if a function returns nothing (#60)
* resolve promise instantly if a function returns nothing * set return value by func.ret Co-authored-by: Dmitry Kurinskiy <dmitry@fluence.one>
This commit is contained in:
parent
28830feafd
commit
c0cdb07bf9
@ -42,6 +42,9 @@ case class TypescriptFunc(func: FuncResolved) {
|
||||
.map(_._2)
|
||||
.fold("void")(typeToTs)
|
||||
|
||||
val returnVal =
|
||||
func.func.ret.fold("Promise.race([promise, Promise.resolve()])")(_ => "promise")
|
||||
|
||||
s"""
|
||||
|export async function ${func.name}(client: FluenceClient${if (func.func.args.isEmpty) ""
|
||||
else ", "}${argsTypescript}): Promise<$retType> {
|
||||
@ -75,7 +78,7 @@ case class TypescriptFunc(func: FuncResolved) {
|
||||
| .build();
|
||||
| });
|
||||
| await client.initiateFlow(request);
|
||||
| return promise;
|
||||
| return ${returnVal};
|
||||
|}
|
||||
""".stripMargin
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user