MCPcopy Index your code
hub / github.com/scriptscat/scriptcat / watch

Method watch

src/pkg/config/config.ts:114–124  ·  view source on GitHub ↗
(
    key: T,
    callback: (value: SystemConfigValueType<T>, prev: SystemConfigValueType<T> | undefined) => void
  )

Source from the content-addressed store, hash-verified

112
113 // 监听配置变更,会使用设置值立即执行一次回调
114 watch<T extends SystemConfigKey>(
115 key: T,
116 callback: (value: SystemConfigValueType<T>, prev: SystemConfigValueType<T> | undefined) => void
117 ) {
118 // 立即执行一次
119 this.get(key).then((val) => {
120 callback(val, undefined);
121 });
122 // 监听变更
123 return this.addListener(key, callback);
124 }
125
126 private resolveDefault<T>(defaultValue: WithAsyncValue<Exclude<T, undefined>>): T | Promise<T> {
127 //@ts-ignore

Callers 1

initManagerMethod · 0.95

Calls 3

getMethod · 0.95
addListenerMethod · 0.95
callbackFunction · 0.85

Tested by

no test coverage detected