MCPcopy Create free account
hub / github.com/angular/angular / on

Method on

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

Source from the content-addressed store, hash-verified

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

Callers 15

promiseExecFunction · 0.45
initializeMethod · 0.45
createPerformWatchHostFunction · 0.45
constructorMethod · 0.45
readMessagesMethod · 0.45
addRemoveCallbackFunction · 0.45
patchMochaFunction · 0.45
patchBluebirdFunction · 0.45
ws-server.jsFile · 0.45
bluebird.spec.tsFile · 0.45

Calls 4

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

Tested by

no test coverage detected