Skip to content

Commit fba957a

Browse files
committed
refactor: remove onOverrideChange callback
1 parent 80ed24d commit fba957a

File tree

2 files changed

+3
-41
lines changed

2 files changed

+3
-41
lines changed

app.js

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -165,20 +165,6 @@ async function initializeLaunchDarkly(clientSideID) {
165165

166166
const eventInterceptionPlugin = new EventInterceptionPlugin();
167167

168-
// Store reference to client for display updates
169-
let ldClient = null;
170-
171-
// Register callback for display updates when overrides change
172-
flagOverridePlugin.onOverrideChange((flagKey, action) => {
173-
if (!ldClient) return;
174-
175-
if (action === 'clear') {
176-
displayFlags(ldClient, flagOverridePlugin);
177-
} else if (flagKey) {
178-
updateFlagDisplay(ldClient, flagKey, flagOverridePlugin);
179-
}
180-
});
181-
182168
const context = {
183169
kind: 'user',
184170
key: 'example-user-' + Math.random().toString(36).substring(7),
@@ -196,9 +182,6 @@ async function initializeLaunchDarkly(clientSideID) {
196182
// Wait for initialization
197183
await client.waitForInitialization();
198184

199-
// Store client reference for use in monkey patches
200-
ldClient = client;
201-
202185
logger.info('LaunchDarkly client initialized successfully');
203186

204187
// Display all flags initially

flag-url-override-plugin.js

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ export function createFlagUrlOverridePlugin(options = {}) {
1919
// Create the underlying plugin
2020
const plugin = new FlagOverridePlugin(overrideOptions);
2121

22-
// Store reference to client for display updates
23-
let ldClient = null;
24-
let updateDisplayCallback = null;
25-
2622
/**
2723
* Load overrides from URL query parameters
2824
*/
@@ -98,37 +94,25 @@ export function createFlagUrlOverridePlugin(options = {}) {
9894
}
9995
}
10096

101-
// Monkey patch setOverride to sync to URL and update display
97+
// Monkey patch setOverride to sync to URL
10298
const originalSetOverride = plugin.setOverride.bind(plugin);
10399
plugin.setOverride = function(flagKey, value) {
104100
originalSetOverride(flagKey, value);
105101
syncOverridesToUrl(this.getAllOverrides());
106-
// Notify callback if registered
107-
if (updateDisplayCallback) {
108-
updateDisplayCallback(flagKey, 'set');
109-
}
110102
};
111103

112-
// Monkey patch removeOverride to sync to URL and update display
104+
// Monkey patch removeOverride to sync to URL
113105
const originalRemoveOverride = plugin.removeOverride.bind(plugin);
114106
plugin.removeOverride = function(flagKey) {
115107
originalRemoveOverride(flagKey);
116108
syncOverridesToUrl(this.getAllOverrides());
117-
// Notify callback if registered
118-
if (updateDisplayCallback) {
119-
updateDisplayCallback(flagKey, 'remove');
120-
}
121109
};
122110

123-
// Monkey patch clearAllOverrides to sync to URL and refresh all flags
111+
// Monkey patch clearAllOverrides to sync to URL
124112
const originalClearAllOverrides = plugin.clearAllOverrides.bind(plugin);
125113
plugin.clearAllOverrides = function() {
126114
originalClearAllOverrides();
127115
syncOverridesToUrl(this.getAllOverrides());
128-
// Notify callback if registered
129-
if (updateDisplayCallback) {
130-
updateDisplayCallback(null, 'clear');
131-
}
132116
};
133117

134118
// Monkey patch registerDebug to load URL overrides
@@ -149,11 +133,6 @@ export function createFlagUrlOverridePlugin(options = {}) {
149133
}
150134
};
151135

152-
// Add helper method to register display update callback
153-
plugin.onOverrideChange = function(callback) {
154-
updateDisplayCallback = callback;
155-
};
156-
157136
// Add helper method to sync initial overrides to URL
158137
plugin.syncInitialOverrides = function() {
159138
const initialOverrides = this.getAllOverrides();

0 commit comments

Comments
 (0)