Effect CommunityEC
Effect Community2mo ago
2 replies
yoggyd

how to proxy the result of an effect

Similar to how you can set accessors: true on a Effect.Service wouldn't it be possible somehow to proxy a lazy loaded module the same way?

What I want to do I.e. is:
const entrypoint = {
  foo: Effect.magicallyProxify(
         Effect.promise(() => import("./foo.js"))
         .pipe(Effect.map(mod => mod.default))
       ))
};

// foo.js

export default class Foo extends Effect.Service<Foo>()("Foo", {
  accessors: true,
  effect: Effect.succeed({
    bar: () => "baz"
  })
}) {}

// usage.js

expect(yield* entrypoint.foo.bar()).to.eq("bar");
Was this page helpful?