-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Describe the feature you'd like
It might be useful to provide a method similar to neq_assign_by that doesn't flip the resulting value.
Is your feature request related to a problem? Please describe. (Optional)
I found myself a little confused here:
fn change(&mut self, props: Self::Properties) -> ShouldRender {
log::debug!(
"Equal {:?}",
self.props.handle.state().session == props.handle.state().session
);
let render = self.props.neq_assign_by(props, |a, b| {
a.handle.state().session == b.handle.state().session || a.id == b.id // ids are equal, so it doesn't assign
});
log::debug!("Should render {:?}", render);
render
}Output:
DEBUG:sonosa_app::pages::record -- Equal false
DEBUG:sonosa_app::pages::record -- Should render false
I needed to use &&, but my train of thought was "render if session changed or id changed".
Describe alternatives you've considered (Optional)
Having the programmer define when to assign rather than when not to assign let's them avoid carrying around an extra not in precious headspace.
Name is still tbd, though I agree with @jstarry:
maybe assign_if
should look to see if there is a rust api naming precedent
assign_by could also work (following the existing scheme). Suggestions are welcome!
fn change(&mut self, props: Self::Properties) -> ShouldRender {
self.props.assign_if(props, |a, b| {
a.handle.state().session != b.handle.state().session || a.id != b.id
})
}Questionnaire
- I'm interested in implementing this myself but don't know where to start
- I would like to add this feature
- I don't have time to add this right now, but maybe later