Skip to content

Instantly share code, notes, and snippets.

@glennblock
Last active December 26, 2015 13:39
Show Gist options
  • Save glennblock/7159969 to your computer and use it in GitHub Desktop.
Save glennblock/7159969 to your computer and use it in GitHub Desktop.
public Func<IDictionary<string, object>, Task<object>> Invoke(Func<IDictionary<string, object>, object> executor)
{
Func<IDictionary<string, object>, Task<object>> invoker = null;
if (executor.Method.ReturnType != typeof (Task<object>))
{
invoker =
p =>
{
var task = new Task<object>(() => executor(p));
task.Start();
return task;
};
}
else
{
invoker = p => (Task<object>) executor(p);
}
return invoker;
}
var edge = require('edge');
var hello = edge.func('scs', function() {/*
Invoke(d=>d["value"])
*/});
hello({"value": "Hello from scriptcs"}, function(error,result) {
if (error) throw error;
console.log(result.Result);
});
var edge = require('edge');
var hello = edge.func('scs', function() {/*
Func<IDictionary<string,object>, Task<object>> execute = p=> Task.FromResult<object>(p["value"]);
execute
*/});
hello({"value": "Hello from scriptcs"}, function(error,result) {
if (error) throw error;
console.log(result.Result);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment