-
Notifications
You must be signed in to change notification settings - Fork 464
[Enhancement/RFC] Background tasks abstraction? #181
Comments
Doesn't Shiny https://github.com/shinyorg/shiny provide this functionality? If so, I think my opinion would be to not add the same functionality in the toolkit for the moment. |
Hey thanks for the info, I didn't know about Shiny. TBH, if Shiny's API is deemed to be better than my Xamarin.Forms.Background lib, I'm fine with that. I opened this github issue to check if it's desirable to include backgrounding features into this XamarinCommunityToolkit, and if we end up with something more similar to Shiny, that's ok too. That said, IMO integrating Shiny's approach would have 2 downsides (compared to Xamarin.Forms.Background): a) It's a lib that includes many more features, so separating the backgrounding bits might be tricky. This is the list of features that Shiny docs highlight:
b) Shiny embraces some dependencies which maybe are not desirable to have in XamarinCommunityToolkit, such as Reactive Extensions (RX) and Microsoft Extension (DI). |
Forgot a 3rd downside: Shiny doesn't seem to support some platforms that Xamarin.Forms.Background supports: macOS, Tizen & Gtk (as they only mention iOS, Android, and UWP in their docs). |
@knocte, for me, this feature fits better in Xamarin.Essentials. |
@pictos agreed, and I also asked in #essentials channel in DotNetEvolution discord and a maintainer also agrees, and later I have found the github issue there: xamarin/Essentials#409 . Closing this then. Thanks. |
Summary
Is there any interest in bringing a background-tasks solution to the CommunityToolkit that abstracts the API of many platforms into one? Doing this with Xamarin.Forms these days is quite a hassle because you need to touch a lot of platform-specific code, e.g. https://xamarinhelp.com/xamarin-background-tasks/
However I've put together a project myself that abstracts all these details into one common API: https://github.com/nblockchain/XamarinFormsBackground (disclaimer: as you can see at the top, my repo is actually a fork from another author; the main difference is it doesn't bring extraneous dependencies such as Reactive Extensions).
If this is a good idea, I can prepare a PR to integrate this into the CommunityToolkit.
API Changes
A background task would then be created like this:
And it would need to be started this way:
Each platform would require a bit of initialization routines (but this initialization code would not need to change everytime more tasks are added or the current tasks are modified, unlike the current state of affairs described in the xamarinhelp.com article above).
The text was updated successfully, but these errors were encountered: