mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-29 11:11:20 -08:00
refactor(core): CORE-18 type builtins and own prompt lifetimes
This commit is contained in:
1 parent
a842058136
commit
98a1800032
55 files changed
+26511
-650
No files matched your search
@@ -0,0 +1,35 @@
|
||||
import type { InfoHost } from './info/poll'
|
||||
import type ResourceScope from './lifecycle/scope'
|
||||
import { pollInfo } from './info/poll'
|
||||
import { getScope, isClosing } from './lifecycle/instance'
|
||||
import { isMobile } from './utils'
|
||||
import Component from './utils/component'
|
||||
|
||||
const states = new WeakMap<Info, { scope?: ResourceScope, revision: number }>()
|
||||
|
||||
export default class Info extends Component<InfoHost> {
|
||||
constructor(art: InfoHost) {
|
||||
super(art)
|
||||
this.name = 'info'
|
||||
states.set(this, { revision: 0 })
|
||||
if (!isMobile)
|
||||
this.init()
|
||||
}
|
||||
|
||||
init(): void {
|
||||
const state = states.get(this)!
|
||||
const revision = ++state.revision
|
||||
state.scope?.dispose()
|
||||
if (isClosing(this.art) || state.revision !== revision)
|
||||
return
|
||||
const scope = getScope(this.art).child()
|
||||
state.scope = scope
|
||||
scope.add(() => {
|
||||
if (state.scope === scope)
|
||||
state.scope = undefined
|
||||
})
|
||||
pollInfo(this.art, scope, () => {
|
||||
this.show = false
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user