Tests
This commit is contained in:
@@ -1,14 +1,21 @@
|
|||||||
import { BunRuntime } from "@effect/platform-bun"
|
import { BunRuntime } from "@effect/platform-bun"
|
||||||
import { Todo } from "@todo-tests/common/data"
|
import { Todo } from "@todo-tests/common/data"
|
||||||
import { Array, Effect } from "effect"
|
import { Array, Console, Effect, Stream } from "effect"
|
||||||
import { TodoRepository, TodoRepositoryLive, createDefaultTodos } from "./TodoRepository"
|
import { TodoRepository, TodoRepositoryLive, createDefaultTodos } from "./TodoRepository"
|
||||||
|
|
||||||
|
|
||||||
|
const watchTodoChanges = Effect.gen(function*() {
|
||||||
|
const todos = yield* TodoRepository
|
||||||
|
yield* Stream.runForEach(todos.todos.changes, todos => Console.log(`Todos changed: ${ todos }`))
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
const main = Effect.gen(function*() {
|
const main = Effect.gen(function*() {
|
||||||
|
const watcher = yield* Effect.fork(watchTodoChanges)
|
||||||
yield* createDefaultTodos
|
yield* createDefaultTodos
|
||||||
|
|
||||||
const todos = yield* TodoRepository
|
const todos = yield* TodoRepository
|
||||||
console.log(yield* todos.todos.get)
|
// console.log(yield* todos.todos.get)
|
||||||
|
|
||||||
const secondTodo = yield* yield* todos.todos.get.pipe(
|
const secondTodo = yield* yield* todos.todos.get.pipe(
|
||||||
Effect.map(Array.get(1))
|
Effect.map(Array.get(1))
|
||||||
@@ -19,7 +26,7 @@ const main = Effect.gen(function*() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
yield* todos.update(secondTodoModified)
|
yield* todos.update(secondTodoModified)
|
||||||
console.log(yield* todos.todos.get)
|
// console.log(yield* todos.todos.get)
|
||||||
})
|
})
|
||||||
|
|
||||||
const runnableMain = main.pipe(
|
const runnableMain = main.pipe(
|
||||||
|
|||||||
Reference in New Issue
Block a user