Skip to content

Headless Task Function Specifications #227

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

Description

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions