Effect CommunityEC
Effect Community2y ago
5 replies
kondaurovdev

Understanding the `match` Functionality

Hello, I don't quite understand how match works.
I want all possible branches to be executed, don't stop on first match

import { Match } from "effect"

const a = {
  message: {
    foo: "bar",
    baz: 1
  }
}

const main = () =>
  Match.value(a).pipe(
    Match.whenAnd(
      { message: { foo: "bar" } }, 
      () => console.log("bar")
    ),
    Match.when(
      { message: { baz: 1 } }, 
      () => console.log("baz")
    ),
    Match.orElse(() => console.log("orElse"))
  )

main()
Was this page helpful?