Implement widget API for signaling the widget to gracefully terminate
In theory, widgets could use iframe unload/beforeunload events for cleanup, but in practice browsers have restrictions on what can be done in those events which may not give sufficient time for clean termination. Signed-off-by: Pauli Virtanen <pav@iki.fi>
This commit is contained in:
parent
355539feb5
commit
1f2bf0485e
2 changed files with 27 additions and 0 deletions
|
@ -87,6 +87,19 @@ export default class WidgetMessaging {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells the widget that it should terminate now.
|
||||
* It is not necessarily called in all instances before the widget is removed,
|
||||
* and the client may force termination with a timeout.
|
||||
* @returns {Promise<*>} Resolves when widget has acknowledged the message.
|
||||
*/
|
||||
terminate() {
|
||||
return this.messageToWidget({
|
||||
api: OUTBOUND_API_NAME,
|
||||
action: KnownWidgetActions.Terminate,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Request a screenshot from a widget
|
||||
* @return {Promise} To be resolved with screenshot data when it has been generated
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue