-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Open
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementationarch-wasmWebAssembly architectureWebAssembly architecturearea-System.Runtime.InteropServices.JavaScriptfeature-request
Milestone
Description
consider some code like this:
public record Todo(int id, int userId, string title, bool completed);
public class SampleApp {
public static async Task<Todo[]> GetTodos() { ... }
}
Right now to make use of something like that from JavaScript, we have to write some boilerplate:
public class SampleApp {
[JSExport]
public static Task<string> GetTodosExportWrapper() => JsonSerializer.SerializeAsync (await GetTodos());
}
// in main.js
const exports = await getAssemblyExports(...);
const json = JSON.parse (await exports.SampleApp.GetTodosExportWrapper());
It would be nice if we had a convenience marshaler for moving Json blobs around:
[JSExport]
[return:JSMarshalAs<JSType.Promise<JSType.Json>>]
public static Task<Todo[]> GetTodos() { ... }
// in main.js
const exports = await getAssemblyExports(...);
const json = await exports.SampleApp.GetTodos ();
pavelsavara, JakeYallop, iXyles, maxkatz6, nulldg and 5 more
Metadata
Metadata
Assignees
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementationarch-wasmWebAssembly architectureWebAssembly architecturearea-System.Runtime.InteropServices.JavaScriptfeature-request