@drauu/core
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -49,2 +49,4 @@ interface Unsubscribe { | ||
update: () => void; | ||
mounted: () => void; | ||
unmounted: () => void; | ||
} | ||
@@ -100,4 +102,5 @@ | ||
get model(): BaseModel<SVGElement>; | ||
get mounted(): boolean; | ||
mount(selector: string | SVGSVGElement): void; | ||
unmounted(): void; | ||
unmount(): void; | ||
on<K extends keyof EventsMap>(type: K, fn: EventsMap[K]): Unsubscribe; | ||
@@ -104,0 +107,0 @@ undo(): boolean; |
@@ -358,3 +358,8 @@ (() => { | ||
} | ||
get mounted() { | ||
return !!this.el; | ||
} | ||
mount(selector) { | ||
if (this.el) | ||
throw new Error("[drauu] already mounted, unmount previous target first"); | ||
if (typeof selector === "string") | ||
@@ -391,6 +396,9 @@ this.el = document.querySelector(selector); | ||
}); | ||
this._emitter.emit("mounted"); | ||
} | ||
unmounted() { | ||
unmount() { | ||
this._disposables.forEach((fn) => fn()); | ||
this._disposables.length = 0; | ||
this.el = null; | ||
this._emitter.emit("unmounted"); | ||
} | ||
@@ -397,0 +405,0 @@ on(type, fn) { |
@@ -371,3 +371,8 @@ var __defProp = Object.defineProperty; | ||
} | ||
get mounted() { | ||
return !!this.el; | ||
} | ||
mount(selector) { | ||
if (this.el) | ||
throw new Error("[drauu] already mounted, unmount previous target first"); | ||
if (typeof selector === "string") | ||
@@ -404,6 +409,9 @@ this.el = document.querySelector(selector); | ||
}); | ||
this._emitter.emit("mounted"); | ||
} | ||
unmounted() { | ||
unmount() { | ||
this._disposables.forEach((fn) => fn()); | ||
this._disposables.length = 0; | ||
this.el = null; | ||
this._emitter.emit("unmounted"); | ||
} | ||
@@ -410,0 +418,0 @@ on(type, fn) { |
{ | ||
"name": "@drauu/core", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "module": "dist/index.mjs", |
Sorry, the diff of this file is not supported yet
43090
1519