mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-10 21:06:15 -08:00
21 lines
513 B
TypeScript
21 lines
513 B
TypeScript
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)
|
|
},
|
|
}
|
|
}
|