MCPcopy
hub / github.com/codeaashu/claude-code / useSettingsChange

Function useSettingsChange

src/hooks/useSettingsChange.ts:7–25  ·  view source on GitHub ↗
(
  onChange: (source: SettingSource, settings: SettingsJson) => void,
)

Source from the content-addressed store, hash-verified

5import type { SettingsJson } from '../utils/settings/types.js'
6
7export function useSettingsChange(
8 onChange: (source: SettingSource, settings: SettingsJson) => void,
9): void {
10 const handleChange = useCallback(
11 (source: SettingSource) => {
12 // Cache is already reset by the notifier (changeDetector.fanOut) —
13 // resetting here caused N-way thrashing with N subscribers: each
14 // cleared the cache, re-read from disk, then the next cleared again.
15 const newSettings = getSettings_DEPRECATED()
16 onChange(source, newSettings)
17 },
18 [onChange],
19 )
20
21 useEffect(
22 () => settingsChangeDetector.subscribe(handleChange),
23 [handleChange],
24 )
25}
26

Callers 3

HooksConfigMenuFunction · 0.85
AppStateProviderFunction · 0.85
useSettingsErrorsFunction · 0.85

Calls 1

onChangeFunction · 0.50

Tested by

no test coverage detected