Comments (6)
Hi
I looked at the source code to refresh my memory. Classes with [EffectMethod] methods in them are registered as Scoped, so you should get the same instance for every method in the same class. If you are seeing something different then I'll need to see a project that reproduces the problem.
You are correct about sharing state. If you inject IState<MyState>
into more than one component then you should get the same state object. Again, if this is not what you are seeing then I'll need a project that reproduces the problem.
from fluxor.
Thank you @mrpmorris for the kind reply. Before I get too deep into creating an example project (which I'm more than happy to do), there's one part of my code that doesn't smell right, which might explain the issue.
In the aforementioned effects class, some of my EffectMethod handlers require access to the state, outside of what I supply in the action object. To make this possible, I inject IState into the effects class using a parameter on the effect class constructor. I then store a private reference to the state, which my methods access. In my mind this should work, but maybe it is the wrong approach?
I have traced the issue to this state reference in my effects class reflecting stale state data.
Example:
private readonly IState<MyState> _myState;
public Effects(IState<MyState> myState)
{
_myState = myState;
}
[EffectMethod]
public async Task HandleMyAction(MyAction action, IDispatcher dispatcher)
{
var foo = _myState.Value.Blerg;
...
dispatcher.Dispatch(new MyResultAction(...));
}
The reason I don't simply pass the necessary parts of the state in the action object is that the effect requires access to tons of state properties, so instantiating the action object would be very cumbersome.
from fluxor.
Sorry to have wasted your time. This behavior was caused by an error in my state class design, not related to Fluxor.
from fluxor.
Can you share any information so others can benefit?
from fluxor.
Normally I would have, but in this case the error was pure stupidity on my part. My state class constructor basically had an error like this:
class MyState {
public int Foo { get; }
public MyState(int foo)
{
Foo = foo;
Foo = 0;
}
}
So the passed value of foo was always ignored.
from fluxor.
Thanks :)
from fluxor.
Related Issues (20)
- 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
- Having troubles with Fluxor in Blazor auto HOT 1
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.