Closed IamMartinPeek closed 4 years ago
Okay I go the fail now, somehow he didnt like that I had 3 Sub-States from the same type. Can someone explain to me how I can reuse a state-type with the same (Sub-)Reducers for other Substates ?
The error happens when creating the sub-reducers: 'Sequence contains more than one matching element'
Hi @IamPeek
I am not aware of the issue you're describing. Can you please provide a short reproduction code so that I can fix the issue?
Thank you.
The State:
The Reducers:
The Selectors:
Here I want to create Sub-Reducers:
Thats the error:
When I delete two of the OrderListStates in the Rootstate it works...
You know what I mean now ? :)
Has something to do with the selectors i guess ? :)
It seems to be, yes. I will add some tests to reproduce your error.
Good. I can reproduce your error. The error comes from here: https://github.com/Odonno/ReduxSimple/blob/cd8ad984e6897e455b8fd684543edbbe260cd694/ReduxSimple/Reducers.Sub.cs#L81-L82
Soooo... you gonna fix it ? :D
Well, I am trying to figure out a solution. The fact is that .NET reflection isn't helping me much on this. I assumed that each nested state would be of a different type. So that I match the type to know which reducers to apply to the given type.
I did it that way because I did not find a way to do the relation with the property path, ex: RootState.NestedState1
. I will check.
The fastest way for you to fix it would be to create 3 different types for each of your nested state.
The other way around for me would be to apply the reducers to all nested state that match the type. But then this...
var reducers1 = CreateSubReducers(
nestedReducers.ToArray(),
SelectNested1 // THIS !
);
...would have no sense anymore.
I am not sure which way is the best way. I will keep looking at the reflection documentation but from now on, I did not find anything useful.
@IamPeek Well, after a deep thinking, I come with a really smart solution to deal with this. I'll use the relentless use of references of C# as its advantage. Because with reference objects, I can test the equality of the updated feature state and all the properties of the parent state.
So, it should work all the time.. and if it doesn't (not sure why) well, there will be no failure because we will fallback to the previous state anyway.
I'll ship a new version soon.
v3.2.0 is now available. Let me know if your project now works like expected.
Thank you for your patience.
Hey Mate its working now. Thank your very much :) Using this Framework for a bachelor thesis by the way :)
Good. What is the subject of your bachelor thesis?
Hey Guys,
you got a cool framework there, but unfortunately it doesn´t work me on Xamarin-App. As soon as I add the Line "Store = new ReduxStore(CreateReducers(), RootState.Initial, false);" to my App.cs, it crashes while creating the Sub-Reducers. Only information i get of exception: System.TypeInitializationException: 'The type initializer for 'MyApp' threw an exception.'
Can you help me ? :)