Comments (4)
State should not have dependencies.
If you need state from somewhere else, you can create an EffectMethod that is triggered by StoreInitializedAction. The Effect can have that dependency injected, take the state it needs, and fire off an action to set up the state you need.
from fluxor.
Thanks.
However, as I mentioned using an Effect/EffectMethod on StoreInitializedAction
get's called after my IImportantDependency
is required.
To be more specific, I have a language lookup/localization service that I created for using in a Blazor server-side web application that I am working on.
Usage: @Localizer["Text"]
, where "Text" is the text to be localized. When a new language is selected, it triggers a Fluxor [action]. So in every component, ["Text",...] will be displayed in that newly selected language.
Since the service is needed while rendering the component, having an [action] set the state via a call to an [EffectMethod]
on StoreInitializedAction
will not work in this case.
I thought of a few possible solutions including (in order of best to worst):
-
Update the service/create Fake to echo the literal value of "Text" if all dependencies have not been initialized. So that I can do
new FakeLocalizer()
as an initial base state. -
I can remove the service from AppState and just use a combination of
[CascadingParameter]
, events, and[Inject]
to get the desired result. -
My least favorite--have the localizer property settable and inject
IState<AppState>
andILocalizer
in the constructor of a derived class ofEffect<StoreInitializedAction>
from fluxor.
You could have your App component comsume state of your translation feature and not call @Body
until State.Value.HasInitialized
. That would only get set to true after the first time a language is set. That way you shouldn't have anything that requires your translation state values until after they've loaded.
from fluxor.
I think that's a great suggestion. I tried both methods, State.Value.HasInitialized
and the FakeLocalizer
and both seem to work just fine.
Thanks again.
from fluxor.
Related Issues (20)
- Fluxor dont work with new template .Net 8 and InteractiveServerRenderMode HOT 2
- Fluxor breaks ErrorBoundary in Blazor Wasm HOT 2
- Fluxor Redux Dev Tools eating ram HOT 5
- Fluxor.Blazor.Web.ReduxDevTools requires script-src 'unsafe-eval' on CSP HOT 1
- Subscribing external events HOT 2
- Blazor server app in used Redux(Fluxor) in asp .net core error Unable to resolve service for type 'Fluxor.IFeature` while attempting to activate 'Fluxor.State` HOT 2
- Dispatch from Polly HOT 4
- Dispatching action in effect - running orders HOT 1
- Fluxor does not seem to work with the new .NET 8 Blazor Web App template HOT 2
- Deadlock when dispatching from store/feature events HOT 3
- Reducer not getting invoked in .NET 8 Blazor HOT 4
- Test case for dispatcher failure in .NET8 with new render modes HOT 6
- 🤑 Add a sponsor button
- Fluxor not updating UI after state change HOT 4
- Getting DisposableCallback after app has been running for a while HOT 5
- .NET MAUI Hybrid App Demo HOT 2
- Enabling Fluxor for lazy-loaded assemblies HOT 3
- Blazor dot net 8 server interactive component does not re-render when state changes via redux tools time travel HOT 1
- GoAction using relative path doesn't work anymore (LocationChangeException) HOT 2
- Can't Upgrade to v6.0.0 HOT 4
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 fluxor.