|
1 | | -import { dispatch, guard } from "decoders"; |
| 1 | +import { taggedUnion } from "decoders"; |
2 | 2 | import { decoder as clickDecoder, LabeledClick } from "./Click"; |
3 | 3 | import { decoder as keyDownDecoder, LabeledKeyDown } from "./KeyDown"; |
4 | 4 | import { LabeledStarted, startedDecoder } from "./Lifecycle"; |
@@ -36,18 +36,16 @@ export type ClientToHost = |
36 | 36 | * @param msg The message requiring validation. |
37 | 37 | */ |
38 | 38 | export function validate(msg: any): ClientToHost { |
39 | | - return guard( |
40 | | - dispatch("msgType", { |
41 | | - publish: publicationDecoder, |
42 | | - registeredKeyFired: keyDownDecoder, |
43 | | - client_started: startedDecoder, |
44 | | - clickFired: clickDecoder, |
45 | | - navRequest: navRequestDecoder, |
46 | | - notifyRequest: notifyDecoder, |
47 | | - toastRequest: notifyDecoder, |
48 | | - modalRequest: modalDecoder, |
49 | | - pageMetadata: pageMetadataDecoder, |
50 | | - promptOnLeave: promptDecoder, |
51 | | - }), |
52 | | - )(msg); |
| 39 | + return taggedUnion("msgType", { |
| 40 | + publish: publicationDecoder, |
| 41 | + registeredKeyFired: keyDownDecoder, |
| 42 | + client_started: startedDecoder, |
| 43 | + clickFired: clickDecoder, |
| 44 | + navRequest: navRequestDecoder, |
| 45 | + notifyRequest: notifyDecoder, |
| 46 | + toastRequest: notifyDecoder, |
| 47 | + modalRequest: modalDecoder, |
| 48 | + pageMetadata: pageMetadataDecoder, |
| 49 | + promptOnLeave: promptDecoder, |
| 50 | + }).verify(msg); |
53 | 51 | } |
0 commit comments