Passing Nested Dependencies in Effect

How to pass dependencies of dependencies to an effect?
const App = Effect.gen(function* ($) {
  const token = yield* $(Config.string("TELEGRAM_TOKEN"));

  // ...
  yield* $(
    Effect.tryPromise(() =>
      pipe(
        Effect.gen(function* ($) {
          const commands = yield* $(Effect.all([BalanceCmd, CreateCmd, StartCmd]));

          // ...
        }),
        Effect.provide(Layer.mergeAll(BalanceCmdLive, CreateCmdLive, StartCmdLive)),
        Effect.provideService(BotInstance, bot),
        Effect.runPromise
      )
    )
  );
});

pipe(App, Effect.provide(SessionLive), BunRuntime.runMain);
Was this page helpful?