You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been using this technique successfully when calling JS functions, but recently when trying the new JS isolation feature, I saw this comment from Steve Sanderson: #28627 (comment)
JavaScript's invoke mechanism is inherently asynchronous - it always returns a Promise - so it's not useful to call it synchronously in this way.
So if invoke is asynchronous and always returns a promise... What's the point of IJSInProcessRuntime?
I might be confused about what Steve calls "Javascript's invoke". Is this different than .NET's IJSInProcessRuntime.Invoke?
In other words, IJSInProcessRuntime.Invoke is going to run synchronously against a regular JS function, but will return a JS promise when run against an import statement?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
According to https://docs.microsoft.com/en-us/aspnet/core/blazor/webassembly-performance-best-practices?view=aspnetcore-5.0#consider-making-synchronous-calls, webassembly-only apps can optimize performance by casting IJSRuntime to IJSInProcessRuntime.
I've been using this technique successfully when calling JS functions, but recently when trying the new JS isolation feature, I saw this comment from Steve Sanderson: #28627 (comment)
JavaScript's invoke mechanism is inherently asynchronous - it always returns a Promise - so it's not useful to call it synchronously in this way.
So if invoke is asynchronous and always returns a promise... What's the point of IJSInProcessRuntime?
I might be confused about what Steve calls "Javascript's invoke". Is this different than .NET's
IJSInProcessRuntime.Invoke
?In other words,
IJSInProcessRuntime.Invoke
is going to run synchronously against a regular JS function, but will return a JS promise when run against an import statement?Beta Was this translation helpful? Give feedback.
All reactions