Skip to content

xzhayon/affex

Repository files navigation

affex

GitHub GitHub Workflow Status Codecov npm

Installation

The package is available via npm:

npm install affex

Usage

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()))

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages