MCPcopy Index your code
hub / github.com/react/react / Bridge

Class Bridge

packages/react-devtools-shared/src/bridge.js:296–331  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

294};
295
296class Bridge<
297 OutgoingEvents: Object,
298 IncomingEvents: Object,
299> extends EventEmitter<{
300 ...IncomingEvents,
301 ...OutgoingEvents,
302}> {
303 _isShutdown: boolean = false;
304 _messageQueue: Array<any> = [];
305 _scheduledFlush: boolean = false;
306 _wall: Wall;
307 _wallUnlisten: Function | null = null;
308
309 constructor(wall: Wall) {
310 super();
311
312 this._wall = wall;
313
314 this._wallUnlisten =
315 wall.listen((message: Message) => {
316 if (message && message.event) {
317 (this: any).emit(message.event, message.payload);
318 }
319 }) || null;
320
321 // Temporarily support older standalone front-ends sending commands to newer embedded backends.
322 // We do this because React Native embeds the React DevTools backend,
323 // but cannot control which version of the frontend users use.
324 this.addListener('overrideValueAtPath', this.overrideValueAtPath);
325 }
326
327 // Listening directly to the wall isn't advised.
328 // It can be used to listen for legacy (v3) messages (since they use a different format).
329 get wall(): Wall {
330 return this._wall;
331 }
332
333 send<EventName: $Keys<OutgoingEvents>>(
334 event: EventName,

Callers

nothing calls this directly

Calls 3

addListenerMethod · 0.65
constructorFunction · 0.50
emitMethod · 0.45

Tested by

no test coverage detected