The package is available via npm:
npm install affex
import { fx } from 'affex'
// Define service interface.
interface Log {
readonly [fx.uri]?: unique symbol
(message: string): void
}
// Create service tag.
const tag = fx.tag<Log>()
// Derive effect constructor.
const log = fx.operation(tag)
// Perform effect in generator function.
function* main() {
yield* log('hello, world')
}
// Create layer with effect handler.
function ConsoleLog() {
return fx.layer(tag, (message) => console.log(message))
}
// Run program with provided context.
fx.runPromise(main, fx.context().with(ConsoleLog()))