tjanczuk / edge

Run .NET and Node.js code in-process on Windows, MacOS, and Linux
http://tjanczuk.github.io/edge
Other
5.42k stars 640 forks source link

Is it possible to return something different than an async Task<object> #716

Closed krm35 closed 3 years ago

krm35 commented 3 years ago

Hello,

Is it possible to return a byte[] to avoid the node.JS callback? from

C#
public async Task<object> Invoke(string input)
{

}

JS
myFunc("input", function (err, res) {

})

to

C#
public  byte[] Invoke(string input)
{

}

JS
const res = myFunc("input");

Thanks.

splitice commented 3 years ago

I'd like to second interest in a synchronous option. Although I am unsure if it makes sense. the .net application is after all in a different thread / process I beleive.

krm35 commented 3 years ago

Found a temporary solution.

const {promisify} = require("util");
const myFuncAsync = promisify(myFunc).bind(myFunc);