Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to await for closure of any viewmodel #4426

Open
Adam-Langley opened this issue Jul 2, 2022 · 3 comments
Open

Ability to await for closure of any viewmodel #4426

Adam-Langley opened this issue Jul 2, 2022 · 3 comments
Labels
t/feature Feature request type

Comments

@Adam-Langley
Copy link

馃殌 Feature Requests

Currently, it is only possible to block until closure of viewmodel that returns a value:

await nav.Navigate<MyViewModel, MyViewModelResult(...);

However, sometimes, I want to perform some work after a child viewmodel has closed - even though it does not return a value.

One might argue "hey, just return a value then!" - however, it means that viewmodel needs to derive from MvxViewModel<TInput, TOutput> instead if MvxViewModel, or MvxViewModel.
As I have my own common viewmodel base class (MyProductsViewModelBase : MvxViewModel), I have to repeat all my code multiple times to have a base class which

  1. has no input or output
  2. has an input
  3. has an input and output

It would be much easier, if the IMvxViewModel just had its own CloseCompletionSource to be notified of when it was closed.

Contextualize the feature

Add a TaskCompletionSource<bool> CloseCompletionSource to the IMvxViewModel contract.
Sure, `IMvxViewModelResult<> would then need to have 2 completion sources (a bool one, and a typed on) - small price to pay.

@entdark
Copy link
Contributor

entdark commented Jul 5, 2022

The ability to await the result in any way got removed: #4299
Feel free to send your callback as a parameter without awaiting for result.

@Cheesebaron
Copy link
Member

Yeah, not going to add it back. Might have missed some of the related code.

If you come up with a good lifecycle aware version of it, I might consider it.

@Cheesebaron Cheesebaron added the t/feature Feature request type label Jan 16, 2023
@Psjdkhna
Copy link

Psjdkhna commented May 5, 2024

Add a TaskCompletionSource CloseCompletionSource to the IMvxViewModel contract.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t/feature Feature request type
Development

No branches or pull requests

4 participants