File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
packages/shared/sdk-client Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -268,7 +268,9 @@ describe('sdk-client object', () => {
268268 const carContext2 : LDContext = { kind : 'car' , key : 'test-car-2' } ;
269269 await ldc . identify ( carContext2 ) ;
270270
271- expect ( emitter . listenerCount ( 'change' ) ) . toEqual ( 1 ) ;
271+ // No default listeners. This is important for clients to be able to determine if there are
272+ // any listeners and act on that information.
273+ expect ( emitter . listenerCount ( 'change' ) ) . toEqual ( 0 ) ;
272274 expect ( emitter . listenerCount ( 'error' ) ) . toEqual ( 1 ) ;
273275 } ) ;
274276
Original file line number Diff line number Diff line change @@ -2,6 +2,12 @@ import { LDLogger } from '@launchdarkly/js-sdk-common';
22
33export type EventName = 'error' | 'change' ;
44
5+ /**
6+ * Implementation Note: There should not be any default listeners for change events in a client
7+ * implementation. Default listeners mean a client cannot determine when there are actual
8+ * application developer provided listeners. If we require default listeners, then we should add
9+ * a system to allow listeners which have counts independent of the primary listener counts.
10+ */
511export default class LDEmitter {
612 private listeners : Map < EventName , Function [ ] > = new Map ( ) ;
713
You can’t perform that action at this time.
0 commit comments