Skip to content

Commit 5f2d878

Browse files
committed
dispatcher: remove old comments
1 parent 589318b commit 5f2d878

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

client/utils/dispatcher.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// https://github.com/codesandbox/codesandbox-client/blob/master/packages/codesandbox-api/src/dispatcher/index.ts
33

44
const frames: {
5-
[key: number]: { frame: Window | null, origin: string }
5+
[key: number]: { frame: Window | null; origin: string };
66
} = {};
77
let frameIndex = 1;
88

@@ -13,7 +13,7 @@ export const MessageTypes = {
1313
FILES: 'FILES',
1414
SKETCH: 'SKETCH',
1515
REGISTER: 'REGISTER',
16-
EXECUTE: 'EXECUTE',
16+
EXECUTE: 'EXECUTE'
1717
// eslint-disable-next-line prettier/prettier
1818
} as const;
1919

@@ -26,8 +26,8 @@ export type MessageType = typeof MessageTypes[keyof typeof MessageTypes];
2626
* - payload: additional data for that message type
2727
*/
2828
export type Message = {
29-
type: MessageType,
30-
payload?: any
29+
type: MessageType;
30+
payload?: any;
3131
};
3232

3333
let listener: ((message: Message) => void) | null = null;
@@ -57,7 +57,7 @@ function notifyListener(message: Message): void {
5757
function notifyFrames(message: Message) {
5858
const rawMessage = JSON.parse(JSON.stringify(message));
5959
Object.values(frames).forEach((frameObj) => {
60-
const { frame, origin } = frameObj
60+
const { frame, origin } = frameObj;
6161
if (frame && frame.postMessage) {
6262
frame.postMessage(rawMessage, origin);
6363
}
@@ -70,10 +70,6 @@ function notifyFrames(message: Message) {
7070
*/
7171
export function dispatchMessage(message: Message | undefined | null): void {
7272
if (!message) return;
73-
74-
// maybe one day i will understand why in the codesandbox
75-
// code they leave notifyListeners in here?
76-
// notifyListener(message);
7773
notifyFrames(message);
7874
}
7975

@@ -89,9 +85,6 @@ export function listen(callback: (message: Message) => void): () => void {
8985

9086
function eventListener(e: MessageEvent) {
9187
const { data } = e;
92-
93-
// should also store origin of parent? idk
94-
// if (data && e.origin === origin) {
9588
if (data) {
9689
notifyListener(data);
9790
}

0 commit comments

Comments
 (0)