Skip to content

Latest commit

 

History

History
57 lines (40 loc) · 1.92 KB

README.md

File metadata and controls

57 lines (40 loc) · 1.92 KB


💁

effect-use

effect-use is a library that collects common Effect wrappers in one place for developer convenience.

Project Status

Alpha software, subject to change.

Packages

Usage

import { GitHub } from '@effect-use/github'
import { Effect, Layer, pipe } from 'effect'

const getLatestCommit = pipe(
  Effect.flatMap(GitHub, github => github.getRepo({owner: 'embedded-insurance', repo: 'effect-use'})),
  Effect.map(result => result.repo.latestCommit),
  Effect.mapError(e => ({ _tag: "Whoops" }))
)

// Let's provide our dependencies
// And instead of the real GitHub, let's just make something up that looks exactly like it.
// a.k.a., "it satisfies the interface"
const GitHubLayerTest = Layer.succeed(GitHub, {
  getRepo: (args: any)=> ({ latestCommit: '125' })
} as GitHub)

const result = pipe(
  getLatestCommit,
  Effect.provide(GitHubLayerTest),
  Effect.runPromise
)

expect(result).toEqual({latestCommit: '125'})