I want to send the result of a pipeline into a switch statement
let onWithOptions = (~key: string, eventName, options: options, decoder) =>
onCB(eventName, key, event => {
...
event |> Tea_json.Decoder.decodeEvent(decoder) |>
switch x {
| Ok(a) => Some(a)
| Error(_) => None
}
})
I have tried to do it this way but it didn't work x is not recognizable in the switch statement
let onWithOptions = (~key: string, eventName, options: options, decoder) =>
onCB(eventName, key, event => {
...
let x = event |> Tea_json.Decoder.decodeEvent(decoder) |>
switch x {
| Ok(a) => Some(a)
| Error(_) => None
}
})
Any idea on how this could be done?