mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-27 17:51:20 -08:00
refactor(core): CORE-14 split typed settings and scope tree lifetimes
This commit is contained in:
1 parent
697817eceb
commit
64d1939daa
51 files changed
+28144
-1519
No files matched your search
@@ -0,0 +1,20 @@
|
||||
import type { SettingItem } from './types'
|
||||
|
||||
const registrations = new WeakMap<SettingItem, object>()
|
||||
|
||||
export function cancelSettingAdd(item: SettingItem): void {
|
||||
registrations.delete(item)
|
||||
}
|
||||
|
||||
export function beginSettingAdd(item: SettingItem): { current: () => boolean, finish: () => void } {
|
||||
const token = {}
|
||||
registrations.set(item, token)
|
||||
const current = () => registrations.get(item) === token
|
||||
return {
|
||||
current,
|
||||
finish() {
|
||||
if (current())
|
||||
registrations.delete(item)
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user