Skip to main content
On this pageOverview

Task

Overview

Foldkit provides utility functions for common side effects that return Commands you can use in your update function.

Task.getTime gets the current UTC time. Task.getZonedTime gets time with the system timezone. Task.getZonedTimeIn gets time in a specific timezone.

import { Effect } from 'effect'
import { Command, Task } from 'foldkit'

const GetTime = Command.define('GetTime', GotTime)
const GetZonedTime = Command.define('GetZonedTime', GotZonedTime)
const GetNyTime = Command.define(
  'GetNyTime',
  SucceededGetNyTime,
  FailedGetTimeZone,
)

const getTime = GetTime(Task.getTime.pipe(Effect.map(utc => GotTime({ utc }))))

const getZonedTime = GetZonedTime(
  Task.getZonedTime.pipe(Effect.map(zoned => GotZonedTime({ zoned }))),
)

const getNyTime = GetNyTime(
  Task.getZonedTimeIn('America/New_York').pipe(
    Effect.map(zoned => SucceededGetNyTime({ zoned })),
    Effect.catchAll(() => Effect.succeed(FailedGetTimeZone())),
  ),
)

Task.focus focuses an element by CSS selector (useful after form submission). Task.randomInt generates random integers.

import { Effect } from 'effect'
import { Command, Task } from 'foldkit'

const FocusEmailInput = Command.define('FocusEmailInput', Focused)
const RollDice = Command.define('RollDice', RolledDice)

const focusEmailInput = FocusEmailInput(
  Task.focus('#email-input').pipe(Effect.ignore, Effect.as(Focused())),
)

const rollDice = RollDice(
  Task.randomInt(1, 7).pipe(Effect.map(value => RolledDice({ value }))),
)

Now that you know how to write Commands and use built-in tasks, the next step is wiring everything together into a running application.

Stay in the update loop.

New releases, patterns, and the occasional deep dive.


Built with Foldkit.

© 2026 Devin Jameson