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

How to stop the headless task? #24

Open
ajaykumar97 opened this issue Jun 6, 2020 · 0 comments
Open

How to stop the headless task? #24

ajaykumar97 opened this issue Jun 6, 2020 · 0 comments

Comments

@ajaykumar97
Copy link

I have successfully implemented the react-native-sync-adapter and is working fine for the foreground and background sync. But the main issue is, I want to stop the sync interval task after single sync. I want to sync the data only once when user taps on the sync button in the application. Can anyone help me how to achieve that?

I am registering the task like:

const TASK_ID = 'TASK_SYNC_ADAPTER';

AppRegistry.registerComponent(appName, () => SyncAdapterExample);
AppRegistry.registerCancellableHeadlessTask(
    TASK_ID,
    () => TestTask,
    () => {},
);

And canceling the task after my operation has been completed in TestTask.js file like:

const TASK_ID = 'TASK_SYNC_ADAPTER';
AppRegistry.cancelHeadlessTask(TASK_ID, TASK_ID);

But I am getting an error while canceling the task:

TypeError: taskCancelProvider() is not a function. (In 'taskCancelProvider()()', 'taskCancelProvider()' is undefined)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant