𝗝𝗮𝗺𝗲𝘀
Cant import scoped Javascript in Blazor Standalone WebAssembly
In the past I have already done this in InteractiveServer Blazor, which is to import
{page}.razor.js
in my razor page through IJSRuntime
in the OnAfterRender
step of the page lifecycle. as follows:
Page.Razor.cs
Page.razor.js
There is a way to make something similar work, by using global javascript files in wwwroot\*.js
and <script...
directives but that is not desired in the moment. I didn't find any way to use a modular aproach handled by the ComponentBase
object.
This is the web assembly startup implementation
Program.cs
.NET Core 9 environment// stack overflow post: https://stackoverflow.com/questions/79542079/cant-import-scoped-javascript-in-blazor-standalone-webassembly
3 replies
Does structs generate inaccessible copies?
Consider the following large structure for the asked questions
Does a local copy is created when returning from a method?
In my understanding of how structure returning methods are handled, the current method will allocate the necessary memory to store the called method's return within the stack. But, the called method also has it's own stack, so, in the next scenarios, does the struct gets copied back in forth or is it internally passed by reference?
When
Main
invokes CreateMe
is the structure allocated inside the creator method or does the compiler detects that no one can access it so it makes new()
allocate directly into x
's var memory?
What if the variable is accessed in the creator method but only returned
Since the value temp
is only modified and then returned, is the memory for it allocated in CreateMe
's stack and then copied to the caller method stack or accessed directly?
Does a a copy of a struct is created when passing through an init accessor?
When creating a Data
instance, the IL method init_Payload
is called. So the stack traces looks something like the following .With that in mind, does the large structure gets copied 2 times or the compiler optmises that in some way?
Main() -> CreateMe() -> init_Payload
new Data() | => new(); | arg: value12 replies
Are streams any better than byte array outside of I.O context?
Streams are visibly better when working with files, network responses and many other cases, but, when specifically working with objects which already live within RAM memory, are streams still useful? I.E why does Binary Formatter used streams when formatting managed objects?
The understanding that I have from streams is a lot like IEnumerable<byte> with a temp buffer, meaning, nothing happens upon creation until fetched.
Maybe postpone an action till last moment?
6 replies