This commit is contained in:
Julien Valverdé
2024-07-09 01:03:45 +02:00
parent 48da2c6489
commit 3ac12bfe3e
3 changed files with 11 additions and 11 deletions

View File

@@ -1,22 +1,22 @@
import { BunRuntime } from "@effect/platform-bun"
import { Todo } from "@todo-tests/common/data"
import { Todo, type IdentifiedTodo } from "@todo-tests/common/data"
import { Identifiable } from "@todo-tests/common/traits"
import { Array, Effect, Layer, Option, Stream } from "effect"
import { Chunk, Effect, Layer, Stream } from "effect"
import { ServicesLive } from "./Services"
import { TodoRepository, createDefaultTodos } from "./TodoRepository"
import { ExpressApp } from "./express/ExpressApp"
import { ExpressHTTPServer } from "./express/ExpressHTTPServer"
import { RPCPlayground } from "./rpc/RPCPlayground"
import { RPCPlaygroundRoute } from "./rpc/RPCPlaygroundRoute"
import { RPCRouter } from "./rpc/RPCRouter"
import { RPCServer } from "./rpc/RPCServer"
import { RPCServerRoute } from "./rpc/RPCServerRoute"
import { RPCProcedureBuilder } from "./rpc/procedures/RPCProcedureBuilder"
import { TRPCBuilder } from "./trpc/TRPCBuilder"
import { TRPCContextCreator } from "./trpc/TRPCContextCreator"
const ServerDev = ExpressHTTPServer.Live.pipe(
Layer.provide(RPCServer.Live),
Layer.provide(RPCPlayground.Dev),
Layer.provide(RPCServerRoute.Live),
Layer.provide(RPCPlaygroundRoute.Dev),
Layer.provide(RPCRouter.Live),
Layer.provide(RPCProcedureBuilder.Live),
Layer.provide(TRPCBuilder.Live),
@@ -30,11 +30,11 @@ const watchTodoChanges = Effect.gen(function*() {
// yield* Stream.runForEach(todos.todos.changes, todos => Console.log(`Todos changed: ${ todos }`))
yield* todos.todos.changes.pipe(
Stream.runFold(
Array.empty<Todo & { id: Option.Some<string> }>(),
Chunk.empty<IdentifiedTodo>(),
(prev, curr) => {
console.log(`Added todos: ${ Array.differenceWith<Todo>(Identifiable.equals)(curr, prev) }`)
console.log(`Removed todos: ${ Array.differenceWith<Todo>(Identifiable.equals)(prev, curr) }`)
console.log(`Added todos: ${ Chunk.differenceWith<Todo>(Identifiable.equals)(curr, prev) }`)
console.log(`Removed todos: ${ Chunk.differenceWith<Todo>(Identifiable.equals)(prev, curr) }`)
return curr
},