On this pageOverview
Messages
Messages represent all the events that can occur in your application. They describe what happened, not how to handle it. Messages are implemented as tagged unions, providing exhaustive pattern matching and type safety.
The counter example has three simple messages:
import { Schema } from 'effect'
import { m } from 'foldkit/message'
// MESSAGE - All possible events that can happen in your application
// Messages are dispatched from the view and handled by the update function
// m wraps Schema.TaggedStruct with a callable constructor — write Foo() instead of Foo.make()
const ClickedDecrement = m('ClickedDecrement')
const ClickedIncrement = m('ClickedIncrement')
const ClickedReset = m('ClickedReset')
const Message = Schema.Union(
ClickedDecrement,
ClickedIncrement,
ClickedReset,
)
type Message = typeof Message.TypeActions without the boilerplate
Messages are similar to Redux action types, but more ergonomic with Effect Schema. Instead of string constants and action creators, you get type inference and pattern matching for free.