mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +01:00
Add types to disposeValue
This commit is contained in:
parent
7772643b0d
commit
dd74ed1957
@ -14,7 +14,10 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function disposeValue(value) {
|
type func = () => void;
|
||||||
|
type Disposable = { dispose: func; [key: string]: any } | func;
|
||||||
|
|
||||||
|
function disposeValue(value: Disposable): void {
|
||||||
if (typeof value === "function") {
|
if (typeof value === "function") {
|
||||||
value();
|
value();
|
||||||
} else {
|
} else {
|
||||||
@ -27,9 +30,7 @@ function isDisposable(value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class Disposables {
|
export class Disposables {
|
||||||
constructor() {
|
private readonly _disposables = [];
|
||||||
this._disposables = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
track(disposable) {
|
track(disposable) {
|
||||||
if (!isDisposable(disposable)) {
|
if (!isDisposable(disposable)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user