Blazor Interop LocalStorage 0.4.0 change to 0.5.1

blazor c# javascript

Question

Since Blazor Interop has recently changed, it is difficult for me to find simple examples to learn from. I thus copied some code from a functioning example and would want to adapt it to the new interop. Here is the code from Blazor 0.4.0 from the.js file.

Blazor.registerFunction('saveToken', token => {
window.localStorage.setItem('jwt', token);
console.log("Authentication token has been stored.");
return true;

});

This is also taken from the Blazor website. functions in csthml

            RegisteredFunction.Invoke<bool>("saveToken", token);

I've previously studied Blazor Doc Interop https://blazor.net/docs/javascript-interop.html, and the example was quite simple to follow, but I'm not sure how to use localstorage.

1
0
7/29/2018 2:18:48 AM

Accepted Answer

ZZZ_tmp
0
7/29/2018 2:35:40 AM

Popular Answer

ZZZ_tmp


Related Questions





Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow