Closed SunlightBro closed 5 years ago
Usually the ViewModel would be a class containing the nullable state piece. What you want is the state piece itself to be the ViewModel. I never thought of using it that way, but I guess it's a valid way of using it. It should be easy to fix this.
What is the error you're getting when you try to do this?
Ok misphrased this a bit, the above mentioned example works fine, as I'm using built_value for all my models I can always be sure that ==()
and hashCode
are implemented.
But as models get more complicated getting a model can become pretty ugly and error prone.
StoreConnector<AppState, String>(
converter: (store) => store.state.pullrequest?.author?.links?.avatar?.href,
builder: (context, href) {...},
The more I think about this, I should just stop being lazy and start using proper ViewModels.
I'll close this issue.
I quite often run into this nuisance, that the first thing in builder function is to check if the Model is null, as some values in the AppState are nullable (e.g. after successful login the User's details are requested via an UserGet ReduxAction, before that
AppState().self
is just null).Is this the intended way or should the
model
orconverter
function not be able to return null ?