Support async methods on the IActivate interface
See original GitHub issueA lot of the initial discussion took place in #245, however my thinking has evolved a bit from then.
The initial plan is as follows.
- Move the
IActivate
interface to async only with sync looking like
Task ActivateAsync(CancellationToken cancellationToken);
I’m not 100% on the “Async” suffix, if this was a new codebase that was async first I’d leave it off, however due to migration it make it easier to show where there are breaking changes.
- Update the protected methods on
Screen
that are overridden to the following
Task OnInitializeAsync(CancellationToken cancellationToken);
Task OnActivateAsync(CancellationToken cancellationToken);
- Update the
ScreenExtensions
such asTryActivate
in similar ways. - Add some helper extension methods that allow activation without a cancellation token.
- Update the Conductor classes in a similar method. This is probably the larger piece of work as it means a lot of methods become async such as
ChangeActiveItem
andActivateItem
.
Anybody have thoughts on this?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:14 (10 by maintainers)
Top Results From Across the Web
Making interface implementations async
I'm currently trying to make my application using some Async methods. All my IO is done through explicit implementations of an interface and ......
Read more >IActivateAudioInterfaceAsyncOpe...
Represents an asynchronous operation activating a WASAPI interface and provides a method to retrieve the results of the activation.
Read more >ActivateAudioInterfaceAsync function (mmdeviceapi.h)
This function enables Windows Store apps to activate certain WASAPI COM interfaces after using Windows Runtime APIs in the Windows.
Read more >Is an interface exposing async functions a leaky abstraction?
I would argue the 'asyncness' of a method is indicated by the fact that it returns a Task . The guidelines for suffixing...
Read more >Designing and Implementing Synchronous vs. ...
If a service method uses the async keyword, it implies that it is an asynchronous method and it might have an await keyword...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
= default(CancellationToken)
since it’s a value type. But default parameter values can cause some silliness in libraries that overloads don’t have.OnInitialize
,OnActivate
lifecycle happens when the former isasync void
.My thought process is to expose the “async” the whole way up the stack, making decisions about “this should be async void to hide stuff” will usually be the wrong decision for someone. Hence
ChangeActiveItemAsync
etc.The main point is that the view models won’t do many things async, just better enable you to do them.
There could be some interesting things we can add where if a conductor is switching between items it can cancel the activation of the previous child view model.
I’ll start looking at it soon - are you going to push a new alpha to nuget or should we just work off of develop?