It makes heavy use of Reflection to get/set the properties on the state objects without CombineReducers() having to know the types of the state objects beforehand. I understand this could be a performance problem.
I also had to use the as keyword within a reducer to cast from object back to the expected state type for access there. I couldn't figure out a better way to handle that situation as I needed to pass to CombineReducers() a Dictionary<string, X> where X represents the reducer function. Again, without knowing the type of state before hand, and the possibility of having multiple methods passed here, each accepting a different type of state object, meant I couldn't specify X with any stricter typing.
I'm brand new to C#, so any suggestions on improvements are welcome :)
NOTE: The code was heavily inspired by @gblue1223's excellent redux-unity3d
This implements an equivalent to Redux's
combineReducers()
.It makes heavy use of Reflection to get/set the properties on the state objects without
CombineReducers()
having to know the types of the state objects beforehand. I understand this could be a performance problem.I also had to use the
as
keyword within a reducer to cast fromobject
back to the expected state type for access there. I couldn't figure out a better way to handle that situation as I needed to pass toCombineReducers()
aDictionary<string, X>
whereX
represents the reducer function. Again, without knowing the type of state before hand, and the possibility of having multiple methods passed here, each accepting a different type of state object, meant I couldn't specifyX
with any stricter typing.I'm brand new to C#, so any suggestions on improvements are welcome :)
NOTE: The code was heavily inspired by @gblue1223's excellent
redux-unity3d