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