Issue with Empty Ref After Update in TypeScript
Hi everyone! Maybe someone has an example of using Ref?
I hav en issue with empty Ref after updating
I hav en issue with empty Ref after updating
export const TokenService = Context.GenericTag<Ref.Ref<string>>("@TokenService");
//....
const TokenLive = Layer.effect(TokenService, Ref.make(""));
const NonceLive = Layer.effect(NonceService, Ref.make(""));
const TaigaServiceLive = Layer.effect(TaigaService, makeTaigaService);
const TelegramClientLive = Layer.effect(TelegramClient, Effect.succeed(client));
const MyServiceLive = Layer.effect(MyService, makeMyService).pipe(
Layer.provide(Http.client.layer),
Layer.provide(TokenLive),
Layer.provide(NonceLive),
Layer.provide(TaigaServiceLive),
Layer.provide(TelegramClientLive),
);
const runnable = Effect.provide(MyService, MyServiceLive).pipe(
// Effect.tap(() => Token.pipe(Effect.flatMap(Ref.get), Effect.map(console.log))),
Effect.tap((m) => m.login().pipe(Effect.map(console.log))),
// Effect.tap(() => Token.pipe(Effect.flatMap(Ref.get), Effect.map(console.log))),
Effect.tap((m) => m.config().pipe(Effect.map(console.log))),
// Effect.tap(() => Nonce.pipe(Effect.flatMap(Ref.get), Effect.map(console.log))),
);
Effect.runPromise(runnable);
//....
const token = yield* _(TokenService);
Effect.tap((accessToken) => token.pipe(Ref.update(() => accessToken)))export const TokenService = Context.GenericTag<Ref.Ref<string>>("@TokenService");
//....
const TokenLive = Layer.effect(TokenService, Ref.make(""));
const NonceLive = Layer.effect(NonceService, Ref.make(""));
const TaigaServiceLive = Layer.effect(TaigaService, makeTaigaService);
const TelegramClientLive = Layer.effect(TelegramClient, Effect.succeed(client));
const MyServiceLive = Layer.effect(MyService, makeMyService).pipe(
Layer.provide(Http.client.layer),
Layer.provide(TokenLive),
Layer.provide(NonceLive),
Layer.provide(TaigaServiceLive),
Layer.provide(TelegramClientLive),
);
const runnable = Effect.provide(MyService, MyServiceLive).pipe(
// Effect.tap(() => Token.pipe(Effect.flatMap(Ref.get), Effect.map(console.log))),
Effect.tap((m) => m.login().pipe(Effect.map(console.log))),
// Effect.tap(() => Token.pipe(Effect.flatMap(Ref.get), Effect.map(console.log))),
Effect.tap((m) => m.config().pipe(Effect.map(console.log))),
// Effect.tap(() => Nonce.pipe(Effect.flatMap(Ref.get), Effect.map(console.log))),
);
Effect.runPromise(runnable);
//....
const token = yield* _(TokenService);
Effect.tap((accessToken) => token.pipe(Ref.update(() => accessToken)))