Closed rickclephas closed 1 year ago
Hmm this would bring some other challenges with more complex hierarchies, like when MyChildViewModel
has another child view model.
Yes, which is not uncommon in our codebase. Also consider lists of child view models.
Actually we could fix that by using @ShouldRefineInSwift
and an extension property instead of a subclass.
@humblehacker do you have an example of such lists? I mean is it just a regular list containing KMMViewModel
s?
We have this, for example:
@NativeCoroutinesState
val tasks: StateFlow<List<TaskViewModel>> = mutableTasks.asStateFlow()
Alright, that should be doable. Do you see any other potential issues or challenges?
We also have maps of view models like this:
@NativeCoroutinesState
val things: StateFlow<Map<Item, ThingViewModel>?> = mutableThings.asStateFlow()
Fixes #39
Usage:
extension MyParentViewModel { var myChildViewModel: MyChildViewModel { childViewModel(__myChildViewModel, at: \.__myChildViewModel) } }
hello, I am facing with the issue regarding child viewmodels, but when I am trying to write extension, I am getting error like Cannot find 'childViewModels' in scope. Something was changed in new versions? I changed in parent viewmodel annotation for inner viewmodel and I wanna write that block of the code above, but I am getting issue. can you help me?
@ldobransky the childViewModel
functions should be available in v1.0.0-ALPHA-10 and above.
If for some reason they aren't please open an issue with some reproduction code.
Fixes #39
Usage: