Designing and Architecting Blazor Applications Flashcards
Why Blazor instead of the well known javascript frameworks?
Written in c# and razor syntax.
Can leverage existing .net standard nuget packages.
Powerfull tooling.
Fully supported by Microsoft.
Blazor also is likelly to be faster than JS due the fact it runs over web assembly.
What does it mean saying that Blazor is make in a “component driven design”?
It means the pages are built using different components. Reusable components.
What are the main benefits of Blazor?
Depenendy Injection, Hosting Options, Standarized Packages, Javascript Interop.
What is the role of a service in a MVC project?
It sits between the controller and the repository. Useful when some business logic is necessary.
When to use parameter dependency injection and when to use constructor dependency injection?
Parameter dependency injection is used for components and the constructor (most common) dependency injection is used for services.
How to inject a logger into a blazor component?
By simply add a inject parameter of the type ILogger
What is a Blazor circuit?
Is the context of a connection of a user/tab to our blazor server (not applicable to Blazor web assembly).
What is a scoped service lifecycle?
It means the same instance of the service will be used along in the same Blazor circuit (aka context)
What is a blazor route constraint?
It allows enforcing a specific param type to a route.
How can we monitor page changes in the blazor app?
With the LocationChanged event from the RouteManager class
What is a razor class library?
Allows creating and consuming common components to achieve re-usability. Can be published as a nuget package.
Only UI components can be packed in razor class lib ?
No… also functional libs can be packed into razor comps.
How to create a nuget package out of a razor class lib?
By simply selecting “Pack” in visual studio.
How to manage user’s state in the app (e.g: grid preferences)?
By using local or session storage.
What is the local storage?
It is owned by the browser and it stores all the tabs… non-secure data… good for keeping user preferences like hidden notifications and etc.