You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I imagine I am just naive coming from other frameworks. But I would like to limit a subscription to a service in a viewmodel that will modify a list of items to only when the viewmodel is loaded in the UI. So I figure I need to hook up IActivatableViewModel but when I do that the this.WhenActivated callback does not have the constructor function scope to set readonly ObservableCollection<> member variables that are backing ReadonlyObservableCollection<> properties bound to the ListBox.
So then the options seems to be
use a RW property of Ienumerable<> or similar to be able to set them asynchronously. I think I get warnings about just using a single collection and modifying the collection instead of replacing it.
Make the viewModel disposable and then pass the responsibility of disposing to the creator. Although this really isn't an option for a viewmodel that is also participating in Routing. Unless I am unaware of a good way to hook into that system's transitions? Also this means the viewmodel needs to be recreated in order to show it again (for navigating back to the page)
EDIT: replaced OAPH with RW property when I remembered OAPH has constructor limitation too.
PS: kinda unrelated but is there a better way to do reactiveUI bindings for items in an Itemssource besides IViewFor<>? Creating ReactiveUserControls for list items with a couple properties is verbose/painful. I am aware I can still just put a datatemplate in the ItemTemplate property but then I lose strongly typed bindings.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I imagine I am just naive coming from other frameworks. But I would like to limit a subscription to a service in a viewmodel that will modify a list of items to only when the viewmodel is loaded in the UI. So I figure I need to hook up
IActivatableViewModel
but when I do that thethis.WhenActivated
callback does not have the constructor function scope to set readonlyObservableCollection<>
member variables that are backingReadonlyObservableCollection<>
properties bound to the ListBox.So then the options seems to be
EDIT: replaced OAPH with RW property when I remembered OAPH has constructor limitation too.
PS: kinda unrelated but is there a better way to do reactiveUI bindings for items in an Itemssource besides
IViewFor<>
? Creating ReactiveUserControls for list items with a couple properties is verbose/painful. I am aware I can still just put a datatemplate in theItemTemplate
property but then I lose strongly typed bindings.Beta Was this translation helpful? Give feedback.
All reactions