Comments (9)
Sounds good!
from piral.blazor.
Where should the appsettings.json live? Should it be in the app shell or in pilets?
My proposal is to support the IConfiguration
via app shell configuration. Now in your app shell you can hand over something to the initialization of piral-blazor
, which determines the key / values. It's then up to you to either read some JSON or gather the configuration from different sources. Would that work?
from piral.blazor.
While it probably isn't the most intuitive way for Blazor WASM developers, who are used to employ appsettings*.json files for that purpose, I can think of various use cases which may require the provision of pilet configuration via the app shell anyway. So yes, your proposed way is fine.
from piral.blazor.
Well, I mean what is "intuitive". If you work in a distributed environment then suddenly such old habits are required to change, so I'd argue not everything that was once established still makes sense in this new context.
The big issue with a local appsettings.json file is that a pilet should be environment independent. As such you just uploaded one static file - i.e., it won't change. Now if you do that the whole point of the appsettings.json is rendered useless, as you usually would want to change / adopt it to the target environment. However, there is already such a mechanism in the standard feed service; its configuration. It can be made per pilet per environment and it is gathered by the app shell. Additionally, the app shell can anyway be environment dependent, making the usual appsettings.json rather an app shell construct than a pilet construct.
Now with the given proposal I think whatever the user wants to go for works. It would even work having an appsettings.json per pilet, which is then consumed by the app shell and distributed to the pilets accordingly. But the important part is that IConfiguration
would work.
from piral.blazor.
That's fine, go for it. I am not sure if I can follow you on this though:
However, there is already such a mechanism in the standard feed service; its configuration. It can be made per pilet per environment and it is gathered by the app shell.
In a Piral.Blazor
pilet, how would I access that configuration where I need it (in Module.cs
)? That bit seems to be missing at the moment. So either way you choose in your implementation, there should be a way to get that configuration into IConfiguration
and use it when setting up DI.
from piral.blazor.
In a Piral.Blazor pilet, how would I access that configuration where I need it (in Module.cs)?
You access it via the IConfiguration
instance. The thing is that the app shell would deliver any kind of global config and put it in the initial config passed to createBlazorApi
, i.e., when setting up Piral.Blazor. With this information (and the local one provided to the pilet directly) the IConfiguration
would be populated appropriately, consisting of global (i.e., available to all Blazor pilets) and local (i.e., only available to the current Blazor pilet) infos.
from piral.blazor.
Alright this is working, e.g.,
public class Module
{
public static void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{
Console.WriteLine("Received configuration is: {0} - {1}", configuration.GetValue<string>("foo"), configuration.GetValue<int>("someThingElse:c"));
services.AddScoped<ExampleJsInterop>();
}
}
Note that the second argument (of type IConfiguration
) is optional. You can just omit it (as beforehand) and it would still work.
from piral.blazor.
Hi @FlorianRappl, I'm unable to get anything from appsettings inside of the Blazor Pilet. I tried moving around appsettings from wwwroot to root of the project, specifying Config
in .csproj, setting copy to output folder, etc. but IConfiguration is always empty. Any help? Also not sure how to define (global) settings that will come to pilet from app shell? I don't see option for that when adding createBlazorApi
from piral.blazor.
This is all fully documented @prepfarm, see: https://github.com/smapiot/Piral.Blazor#overwriting-the-debug-meta-data
As the configuration is distributed the IConfiguration
is drawn from the given options to the pilet. For local debugging you can (as documented) use the meta.json file.
Hope that helps!
from piral.blazor.
Related Issues (20)
- render exception using an injected viewmodel HOT 2
- blazor.boot.json not found HOT 4
- Uncaught Error: Collection was modified HOT 1
- piral-adal not working with blazor from app-shell HOT 8
- Event listener is not removed HOT 4
- Duplicated config generation HOT 2
- SupplyParameterFromQuery Binding HOT 9
- Custom NpmRegistry: Sequence contains no elements HOT 1
- PiralQueryParameter availablility HOT 2
- Dynamic Propertybindig for Extensions HOT 2
- Visual Studio Breakpoints Issue HOT 1
- link target blank handling HOT 2
- Pilet start from IDE broken HOT 1
- Add support for the @layout attribute and nested routes HOT 1
- [.NET 8.0] Breakpoints not hit HOT 12
- Debugging of Referenced Project Assemblies HOT 1
- Since upgrade to .NET 8 localization is broken HOT 2
- Rerendering extensions when parameters change HOT 2
- Single entrypoint per pilet HOT 1
- Piral Extension Components do not render when used inside MudDialog HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from piral.blazor.