Skip to content

Commit 84f127d

Browse files
committed
Implement match for WsPayloadActions
Removing toString as it's not needed in the new version of RTK.
1 parent 3c3c556 commit 84f127d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

ui/frontend/websocketActions.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { PayloadAction } from '@reduxjs/toolkit';
1+
import { PayloadAction, isAction } from '@reduxjs/toolkit';
22
import z from 'zod';
33

44
export type WsPayloadAction<P = void, T extends string = string> = PayloadAction<
@@ -12,8 +12,9 @@ export const createWebsocketResponseAction = <P, T extends string = string>(type
1212
throw 'Should never be executed by JS';
1313
}
1414
actionCreator.type = type;
15-
actionCreator.toString = () => type;
16-
// TODO: Add .match() ?
15+
actionCreator.match = function (action: unknown): action is WsPayloadAction<P, T> {
16+
return isAction(action) && action.type === type;
17+
};
1718

1819
return actionCreator;
1920
};

0 commit comments

Comments
 (0)