Skip to content

some effect roasting improvements#16

Open
fiws wants to merge 1 commit intomainfrom
push-yxnonppvomqp
Open

some effect roasting improvements#16
fiws wants to merge 1 commit intomainfrom
push-yxnonppvomqp

Conversation

@fiws
Copy link
Copy Markdown
Collaborator

@fiws fiws commented Apr 8, 2026

https://youtu.be/BzXg0A5Xsv8?t=3437

So.. about the withBrowser: it still remains for now because of api breakage, but also because i'm not sure what a better api would be.

How this is supposed to work

You setup your base configuration once: What browser do i want? what settings?
This is the PlaywrightEnvironment. Basically just a service that knows how to start a browser. See here https://github.com/Jobflow-io/effect-playwright#playwrightenvironment-experimental

withBrowser is then supposed to actually launch the browser (with scope). It is supposed to be used multiple times like:

// launches one browsers
const program = Effect.gen(function* () {
  yield* checkOldEffectWebsite;
  yield* checkNewEffectWebsite;
}).pipe(PlaywrightEnvironment.withBrowser);

// launches two browsers
yield* checkOldEffectWebsite.pipe(PlaywrightEnvironment.withBrowser);
yield* checkNewEffectWebsite.pipe(PlaywrightEnvironment.withBrowser);

New api?

So how would this API look without using Effect.provide internaly? Something like this?

export const browserLayer = Layer.scoped(
  PlaywrightBrowser,
  PlaywrightEnvironment.pipe(
    Effect.flatMap((e) => e.browser),
  ),
).pipe(Layer.fresh); // we want this to be re-created, to be able to launch multiple browsers

// in application code
const program = Effect.gen(function* () {
  const browser = yield* PlaywrightBrowser;
  const page = yield* browser.newPage();
  yield* page.goto("https://example.com");
}).pipe(Effect.provide(browserLayer)); // PlaywrightEnvironment also needs to be provided

or export const browserLayer = () => Layer.scoped(…) to remove the Layer fresh and make it more explicit that a new layer is created?

@fiws fiws force-pushed the push-yxnonppvomqp branch from d4a6a5b to ff8e7f1 Compare April 8, 2026 20:19
@fiws fiws force-pushed the push-yxnonppvomqp branch from ff8e7f1 to c80ab6c Compare April 8, 2026 20:25
@fiws fiws self-assigned this Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant