Skip to content

Commit

Permalink
feat(omi): new lifecycle: ready
Browse files Browse the repository at this point in the history
  • Loading branch information
dntzhang committed Jan 30, 2024
1 parent 57c4934 commit ba57730
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/omi/omi.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ declare namespace Omi {
interface WeElement<P> extends HTMLElement {
install?(): void;
installed?(): void;
ready?(): void;
uninstall?(): void;
beforeUpdate?(): void;
updated?(): void;
Expand All @@ -78,6 +79,7 @@ declare namespace Omi {
interface Component<P> extends HTMLElement {
install?(): void;
installed?(): void;
ready?(): void;
uninstall?(): void;
beforeUpdate?(): void;
updated?(): void;
Expand Down
2 changes: 1 addition & 1 deletion packages/omi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "omi",
"version": "7.6.4",
"version": "7.6.5",
"scripts": {
"start": "vite",
"dev-vite": "vite",
Expand Down
7 changes: 7 additions & 0 deletions packages/omi/src/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@ export class Component extends HTMLElement {
this.installed()
this.fire('installed', this)
this.isInstalled = true

Promise.resolve().then(() => {
this.ready()
this.fire('ready', this)
})
}

disconnectedCallback(): void {
Expand Down Expand Up @@ -392,6 +397,8 @@ export class Component extends HTMLElement {

installed() {}

ready() {}

uninstall() {}

beforeUpdate() {}
Expand Down
2 changes: 1 addition & 1 deletion packages/omi/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ export { Signal } from 'reactive-signal'
export { css } from './css-tag'
export { mixin, globalCSS } from './options'
export { registerDirective } from './directive'
export const version = '7.6.4'
export const version = '7.6.5'

0 comments on commit ba57730

Please sign in to comment.