Unidux
Unidux copied to clipboard
Can we have nested StateElement?
Can we have deep nested of StateElement?
@benzsuankularb Sorry for late response!
Now not supporting deepnested StateElement, because Store class cannot reset nested property.
- https://github.com/mattak/Unidux/blob/master/Assets/Plugins/Unidux/Scripts/Core/Store.cs#L107
- https://github.com/mattak/Unidux/blob/459a71370d889c5265f9dbfb1907780ec025dd6e/Assets/Plugins/Unidux/Scripts/Util/StateUtil.cs#L55-L84
I think it should support nested StateElement. I'll work to fix it on my free time. and of course PR is always welcome!
the store class does not reset properly but the change for this I believe is
public static void ResetStateChanged(IStateChanged state)
{
if (state != null)
{
state.SetStateChanged(false);
}
var properties = state.GetType().GetProperties();
foreach (var property in properties)
{
var value = property.GetValue(state, null);
if (value != null && value is StateElement)
{
ResetStateChanged((IStateChanged)value);
}
if (value != null && value is IStateChanged)
{
var changedValue = (IStateChanged) value;
changedValue.SetStateChanged(false);
}
}
var fields = state.GetType().GetFields();
foreach (var field in fields)
{
var value = field.GetValue(state);
if (value != null && value is StateElement)
{
ResetStateChanged((IStateChanged)value);
}
if (value != null && value is IStateChanged)
{
var changedValue = (IStateChanged) value;
changedValue.SetStateChanged(false);
}
}
}
How do we file PRs for this project? Is there some sort of system in place? @mattak Are there other changes that need to be in place for this to work?