Cancellation of long-running actions
Starting from version 0.8.0, background long-running actions, such as loading onboardings, single stories and in-app
messages, can be canceled. To do this, you can use the CancelableOperation object that is returned by methods of the
actions listed above.
CancelableOperationis returned by methods:showOnboardings,showStory,showStoryOnce,showIAMById,showIAMByEventfromInAppStoryManager- The
cancel()method returnsbool:true- cancellation applied (display hasn't started yet)false- cancellation not applied (display has already started or token was already cancelled)
Examples
All cancellable methods now return an optional CancelableOperation value that allows cancelling the operation
CancelableOperation<bool> showStory(...);
CancelableOperation<bool> showStoryOnce(...);
CancelableOperation<bool> showOnboardings(...);
CancelableOperation<bool> showIAMById(...);
CancelableOperation<bool> showIAMByEvent(...);
void showStory(String storyId) {
final operation = InAppStoryManager.instance.showStory(storyId);
operation.cancel();
}