Skip to content
This repository was archived by the owner on Jul 30, 2018. It is now read-only.
This repository was archived by the owner on Jul 30, 2018. It is now read-only.

Add widget unmount lifecycle method #766

@nicknisi

Description

@nicknisi

Enhancement

Currently, there doesn't appear to be a way to tie into the widget lifecycle for when a widget is unmounted. This can be useful for cleanup activities that should occur, such as cleaning up event listeners (that can't be replaced with property callbacks) when a widget is unloaded.

Package Version: 0.1.2

Code

class Widget extends WidgetBase {
	constructor() {
		super();
		global.addEventListener('message', this.doSomething);
	}

	doSomething: () => {};

	// There's currently not a place to cleanup this event listener
}

Expected behavior:

class Widget extends WidgetBase {
	constructor() {
		super();
		global.addEventListener('message', this.doSomething);
	}

	doSomething: () => {};

	onUmount() {
		global.removeEventListener('message', this.doSomething);
	}

}

Actual behavior:
There currently doesn't seem to be a hook into the lifecycle to accomplish this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions