MCPcopy
hub / github.com/angular/angular / on

Method on

devtools/src/iframe-message-bus.ts:22–37  ·  view source on GitHub ↗
(topic: E, cb: Events[E])

Source from the content-addressed store, hash-verified

20 }
21
22 override on<E extends keyof Events>(topic: E, cb: Events[E]): () => void {
23 const listener = (e: MessageEvent) => {
24 if (!e.data || e.data.source !== this.destination || !e.data.topic) {
25 return;
26 }
27 if (e.data.topic === topic) {
28 (cb as () => void).apply(null, e.data.args);
29 }
30 };
31 window.addEventListener('message', listener);
32 this.listeners.push(listener);
33 return () => {
34 this.listeners.splice(this.listeners.indexOf(listener), 1);
35 window.removeEventListener('message', listener);
36 };
37 }
38
39 override once<E extends keyof Events>(topic: E, cb: Events[E]): void {
40 const listener = (e: MessageEvent) => {

Callers 14

promiseExecFunction · 0.45
initializeMethod · 0.45
createPerformWatchHostFunction · 0.45
addRemoveCallbackFunction · 0.45
patchMochaFunction · 0.45
patchBluebirdFunction · 0.45
ws-server.jsFile · 0.45
bluebird.spec.tsFile · 0.45
electron.jsFile · 0.45
events.spec.tsFile · 0.45
process.spec.tsFile · 0.45

Calls 4

indexOfMethod · 0.80
addEventListenerMethod · 0.65
removeEventListenerMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected