Refactoring the code to make it cleaner and more readable can be achieved by breaking down the lo...
Is there a nicer way to do this sort of thing?
export class AuthClient extends Effect.Service<AuthClient>()("AuthClient", {
accessors: true,
dependencies: [
RpcClient.layerProtocolHttp({ url: `${getBaseUrl()}/api/auth` }).pipe(
Layer.provide(RpcSerialization.layerNdjson),
Layer.provide(FetchHttpClient.layer),
),
],
scoped: Effect.gen(function* () {
const rpc = yield* RpcClient.make(AuthRpcGroup);
return {rpc};
}),
}) {}
export const AuthClientLayer = AuthClient.Default.pipe(
Layer.provide(Logger.minimumLogLevel(LogLevel.Trace)),
Layer.provide(Logger.pretty),
);
export const AuthClientRuntime = ManagedRuntime.make(AuthClientLayer);
export const signOut = () => AuthClient.rpc.pipe(Effect.flatMap(_=>_.SignOut()), AuthClientRuntime.runPromise)export class AuthClient extends Effect.Service<AuthClient>()("AuthClient", {
accessors: true,
dependencies: [
RpcClient.layerProtocolHttp({ url: `${getBaseUrl()}/api/auth` }).pipe(
Layer.provide(RpcSerialization.layerNdjson),
Layer.provide(FetchHttpClient.layer),
),
],
scoped: Effect.gen(function* () {
const rpc = yield* RpcClient.make(AuthRpcGroup);
return {rpc};
}),
}) {}
export const AuthClientLayer = AuthClient.Default.pipe(
Layer.provide(Logger.minimumLogLevel(LogLevel.Trace)),
Layer.provide(Logger.pretty),
);
export const AuthClientRuntime = ManagedRuntime.make(AuthClientLayer);
export const signOut = () => AuthClient.rpc.pipe(Effect.flatMap(_=>_.SignOut()), AuthClientRuntime.runPromise)