export function makeEffectLoader<R, E, A>(
generator: (
context: Route.LoaderArgs
) => Generator<Effect.Effect<R, E, A>, A, unknown>
): (context: Route.LoaderArgs) => Promise<A> {
return async (context: Route.LoaderArgs): Promise<A> => {
// ****
// Type 'Effect<R, E, A>' is missing the following properties from type 'YieldWrap<Effect<any, any, any>>': #private, [YieldWrapTypeId]
const program: Effect.Effect<A, Error, ServiceContext> = Effect.gen(() =>
generator(context)
);
// (alias) type ServiceContext = Context<GreeterService | GreeterClient>
return Effect.runPromise(
// ts: Argument of type 'Effect<A, Error, Context<GreeterService | GreeterClient>>' is not assignable to parameter of type 'Effect<A, Error, never>'.
// Type 'Context<GreeterService | GreeterClient>' is not assignable to type 'never'.
Effect.provide(program, context.context.serviceContext)
);
};
}
export function makeEffectLoader<R, E, A>(
generator: (
context: Route.LoaderArgs
) => Generator<Effect.Effect<R, E, A>, A, unknown>
): (context: Route.LoaderArgs) => Promise<A> {
return async (context: Route.LoaderArgs): Promise<A> => {
// ****
// Type 'Effect<R, E, A>' is missing the following properties from type 'YieldWrap<Effect<any, any, any>>': #private, [YieldWrapTypeId]
const program: Effect.Effect<A, Error, ServiceContext> = Effect.gen(() =>
generator(context)
);
// (alias) type ServiceContext = Context<GreeterService | GreeterClient>
return Effect.runPromise(
// ts: Argument of type 'Effect<A, Error, Context<GreeterService | GreeterClient>>' is not assignable to parameter of type 'Effect<A, Error, never>'.
// Type 'Context<GreeterService | GreeterClient>' is not assignable to type 'never'.
Effect.provide(program, context.context.serviceContext)
);
};
}