This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function utf8ToString(h, p) { | |
let s = ""; | |
for (i = p; h[i]; i++) { | |
s += String.fromCharCode(h[i]); | |
} | |
return s; | |
} | |
let m = new WebAssembly.Instance(new WebAssembly.Module(buffer)); | |
let h = new Uint8Array(m.exports.memory.buffer); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getString () { | |
return "Hello world"; | |
} | |
const value = getString(); | |
console.log(value); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace BlazorExport | |
{ | |
using System; | |
public static class Helper | |
{ | |
public static string Log(string msg) { | |
Console.WriteLine(msg); | |
return "success"; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Blazor.registerFunction('invoke', msg => { | |
const logMethod = Blazor.platform.findMethod( | |
'StandaloneApp', // Assembly name | |
'BlazorExport', // Namespace | |
'Helper', // Class name | |
'Log' // Method name | |
); | |
const wasmResult = Blazor.platform.callMethod(logMethod, null, [ | |
Blazor.platform.toDotNetString('Invoke from JS') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const log = Blazor.platform.findMethod( | |
'BlazorExport', // Assembly name | |
'BlazorExport', // Namespace | |
'Helpers', // Class name | |
'Log' // Method name | |
); | |
log('Invoke from JS'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace BlazorExport | |
{ | |
public static class Helpers | |
{ | |
public static void Log(string msg) | |
{ | |
Console.WriteLine(msg); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void TriggerJsConsoleLog() | |
{ | |
RegisteredFunction.Invoke<bool>( | |
"JavaScriptConsoleLog", | |
"Invoked from Blazor"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Blazor.registerFunction('JavaScriptConsoleLog', message => { | |
console.log(message); | |
return true; | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Layout(typeof(MainLayout)), Route("/fetchdata"), Route("/fetchdata/{StartDate:datetime}")] | |
public class FetchData : BlazorComponent | |
{ | |
// Fields | |
[DebuggerBrowsable(0), CompilerGenerated] | |
private DateTime <StartDate>k__BackingField; | |
private WeatherForecast[] forecasts; | |
[DebuggerBrowsable(0), CompilerGenerated] | |
private HttpClient <Http>k__BackingField; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Route("/counter"), Layout(typeof(MainLayout))] | |
public class Counter : BlazorComponent | |
{ | |
private int currCount = 0; | |
protected override void BuildRenderTree(RenderTreeBuilder builder) | |
{ | |
base.BuildRenderTree(builder); | |
builder.OpenElement(0, "h1"); | |
builder.AddContent(1, "Counter"); |