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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Headless Task Function Specifications #227

Closed
a-k-o-r-e-d-e opened this issue Jun 19, 2021 · 4 comments
Closed

Headless Task Function Specifications #227

a-k-o-r-e-d-e opened this issue Jun 19, 2021 · 4 comments
Labels

Comments

@a-k-o-r-e-d-e
Copy link

a-k-o-r-e-d-e commented Jun 19, 2021

Is your feature request related to a problem? Please describe.
When Initialising the headless function we pass our implementation of the headless function.

While the Documentation clearly shows that we need a function that takes a single HeadlessTask data type.
The "registerHeadlessTask(Function callback)" implementation Just accepts a Function callback, meaning one could mistakenly pass it a Function (String taskId) or Function (int taskId) and the compiler won't raise an issue. This is a mistake I made and I spent a significant amount of time trying to figure out why my headless tasks were not firing but the background tasks were being called when the app is in the foreground.

I admit this was my mistake and could have been prevented if I followed the documentation to the letter but I suggest that the Implementation be tightened so as to prevent others from having such errors.

Describe the solution you'd like
Change the declaration of "BackgroundFetch.registerHeadlessTask(Function callback)" to something like "BackgroundFetch.registerHeadlessTask(Function(HeadlessTask) callback)" hence the compiler would flag it if one passes the wrong fucntion type.

** Edit
While at we could also improve the BackgroundFetch.configure parameter "onFetch" Function declaration from "Function onFetch" to "Function(String taskId) onFetch".
I also suggest the same for the "onTimeout" parameter

@christocracy
Copy link
Member

Why not make a pull-request?

@a-k-o-r-e-d-e
Copy link
Author

a-k-o-r-e-d-e commented Jun 20, 2021

Okay, Gimme a moment.

@stale
Copy link

stale bot commented Aug 21, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and I will leave this open.

@stale stale bot added the stale label Aug 21, 2021
@stale
Copy link

stale bot commented Aug 28, 2021

Closing this issue after a prolonged period of inactivity. Fell free to reopen this issue, if this still affecting you.

@stale stale bot closed this as completed Aug 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants