<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Evangeline Rome</title>
    <description>The latest articles on DEV Community by Evangeline Rome (@nikelborm).</description>
    <link>https://dev.to/nikelborm</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1057423%2F7262cb25-c01f-435d-af0c-d2e7df0178ec.png</url>
      <title>DEV Community: Evangeline Rome</title>
      <link>https://dev.to/nikelborm</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nikelborm"/>
    <language>en</language>
    <item>
      <title>About eager-init services in Effect.ts</title>
      <dc:creator>Evangeline Rome</dc:creator>
      <pubDate>Fri, 20 Nov 2026 13:44:28 +0000</pubDate>
      <link>https://dev.to/nikelborm/about-eager-init-services-in-effectts-3a77</link>
      <guid>https://dev.to/nikelborm/about-eager-init-services-in-effectts-3a77</guid>
      <description>&lt;p&gt;&lt;strong&gt;Evangeline Rome:&lt;/strong&gt;&lt;br&gt;
and even with &lt;code&gt;Deferred&lt;/code&gt; you can do it way fucking cooler&lt;br&gt;
✨ lazy services ✨&lt;br&gt;
so they don't block application start&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/nikelborm/effect-garden/blob/da25498ba088addfaedd0227ae2fc8eac4895ec4/apps/next-midi-demo/app/services/DeferredMIDIAccessService.ts#L32" rel="noopener noreferrer"&gt;nikelborm/effect-garden/.../DeferredMIDIAccessService.ts&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/nikelborm/effect-garden/blob/da25498ba088addfaedd0227ae2fc8eac4895ec4/apps/next-midi-demo/app/helpers/toStatusStream.ts#L7" rel="noopener noreferrer"&gt;nikelborm/effect-garden/.../toStatusStream.ts&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;honestly I could've easily generalized this wrapper with the lazy service, and I even have a half-started version of it somewhere in my playground&lt;br&gt;
but I was too lazy to finish it&lt;br&gt;
this approach has a potential downside&lt;br&gt;
namely that errors from creating the layer are no longer tracked in the layer itself, and every individual consumer of this implementation will see in the type system how it failed during initialization&lt;br&gt;
so you'd have to handle the same error in lots of places and potentially decide individually, every time, what to do with it, instead of doing it once at the layer level&lt;br&gt;
look at the second file&lt;br&gt;
this approach also has an additional upside that's just as underrated&lt;br&gt;
&lt;a href="https://github.com/nikelborm/effect-garden/blob/da25498ba088addfaedd0227ae2fc8eac4895ec4/apps/next-midi-demo/app/services/DeferredAudioContextService.ts" rel="noopener noreferrer"&gt;nikelborm/effect-garden/.../DeferredAudioContextService.ts&lt;/a&gt;&lt;br&gt;
specifically look at this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="n"&gt;currentTime&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Effect&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;flatMap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;deferredAudioContext&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nc"&gt;EAudioContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;currentTime&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;

&lt;span class="n"&gt;decodeAudioData&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;encodedAudioBuffer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;ArrayBuffer&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
  &lt;span class="nc"&gt;Effect&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;flatMap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;deferredAudioContext&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nc"&gt;EAudioContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;decodeAudioData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;encodedAudioBuffer&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;

&lt;span class="n"&gt;createPlayback&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;the methods get forwarded transparently&lt;br&gt;
so if the implementation hasn't been built yet they just hang waiting&lt;br&gt;
and if it has, the methods get called on the implementation immediately&lt;br&gt;
AND&lt;br&gt;
in regular layers&lt;br&gt;
different implementations can fail with different errors&lt;br&gt;
and those get tracked in the layer's types&lt;br&gt;
this approach only works fine when there's basically one implementation overall&lt;br&gt;
because you'll have to force all the errors into one implementation (one service shape/interface), or wrap them in some &lt;code&gt;GeneralAudioContextAcquireFailure { cause: unknown }&lt;/code&gt; that every method of the service will carry&lt;br&gt;
like, you've got just one tag&lt;br&gt;
and the service type is hardcoded in it, including the whole list of errors every method of the service implementation can return&lt;br&gt;
same shit they were going on about with "don't leak dependencies in implementation"&lt;br&gt;
so here we're leaking them, on purpose, and not just them&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;replying to Evangeline Rome:&lt;/em&gt;&lt;br&gt;
&lt;a href="https://github.com/nikelborm/effect-garden/blob/da25498ba088addfaedd0227ae2fc8eac4895ec4/apps/next-midi-demo/app/services/DeferredMIDIAccessService.ts#L32" rel="noopener noreferrer"&gt;nikelborm/effect-garden/.../DeferredMIDIAccessService.ts&lt;/a&gt;...&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;btw "lazy" isn't quite the right word for them here. they don't start building at the moment someone requests them. they're more non-blocking, or eager to return. they start building immediately at app start, but since using them is optional and triggered by later user actions, there's no point blocking the whole app, and waiting for the build to finish can be pushed off until the exact moment they're actually needed&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;replying to Evangeline Rome:&lt;/em&gt;&lt;br&gt;
&lt;a href="https://github.com/nikelborm/effect-garden/blob/da25498ba088addfaedd0227ae2fc8eac4895ec4/apps/next-midi-demo/app/services/DeferredMIDIAccessService.ts#L32" rel="noopener noreferrer"&gt;nikelborm/effect-garden/.../DeferredMIDIAccessService.ts&lt;/a&gt;...&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;on the frontend, naively shoving things into layers like this gives a pretty mediocre result&lt;br&gt;
because the moment you get even ONE layer that takes some time to run, that's it. we're fucked. the whole app freezes on the frontend and the user can't click anything because the app's whole layer hasn't finished building&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Friend A:&lt;/strong&gt;&lt;br&gt;
but then doesn't a popup show up so the user has to click somewhere?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Evangeline Rome:&lt;/strong&gt;&lt;br&gt;
in my case, if I don't use this approach, the permission request to MIDI devices, which hangs the whole time until the user grants it, will freeze the entire app and all interactions&lt;br&gt;
creating an audio context takes 200 ms&lt;br&gt;
creating a MIDI context takes anywhere from 200 to infinity&lt;br&gt;
creating the root OPFS directory that everybody wants to use via DI&lt;br&gt;
same thing&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Friend A:&lt;/strong&gt;&lt;br&gt;
maybe launch them in parallel? or is it synchronous?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Evangeline Rome:&lt;/strong&gt;&lt;br&gt;
I'm launching everything in parallel&lt;br&gt;
it's all async&lt;br&gt;
but what's rendered on my buttons is streams&lt;br&gt;
and all user inputs are also read as reactive streams&lt;br&gt;
the whole app, I've got a lot of web APIs that depend on and interact with each other&lt;br&gt;
and to make a button interactive I shouldn't have to wait for the webmidi system to initialize&lt;br&gt;
to make a button interactive I need to wait for the status from OPFS to find out whether we've downloaded the audio file or not&lt;br&gt;
and until all the layers are built, the runtime won't start executing the main effect they're provided to&lt;br&gt;
so if even one layer isn't eager, it'll freeze the whole app and all interactions and kill responsiveness&lt;br&gt;
and unfortunately the fairy tale that goes "just make small separate AtomRuntimes" doesn't help here&lt;br&gt;
because all the &lt;code&gt;onClick&lt;/code&gt;s, all the streaming of audio assets, everything lives in an effect and is rendered from the cached filesystem state and the playback-queue state machine&lt;br&gt;
and they depend on each other&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Friend A:&lt;/strong&gt;&lt;br&gt;
I feel like the service availability problem fundamentally can't be solved&lt;br&gt;
but maybe you could somehow reconfigure the &lt;code&gt;Scheduler&lt;/code&gt; for the browser?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Evangeline Rome:&lt;/strong&gt;&lt;br&gt;
I haven't dug down to those depths myself&lt;br&gt;
something else is needed here, I think&lt;br&gt;
conceptually I get the feeling that the whole two-stage &lt;code&gt;Layer&lt;/code&gt; system doesn't fit&lt;br&gt;
that context is one simple object built once&lt;br&gt;
that &lt;code&gt;yield* Tag&lt;/code&gt; isn't a reactive subscription to wait for the moment a service gets built&lt;br&gt;
so:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Friend A:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;replying to Evangeline Rome:&lt;/em&gt;&lt;br&gt;
that &lt;code&gt;yield* Tag&lt;/code&gt; isn't a reactive subscription to...&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;yeah, here you could actually use &lt;code&gt;Effectable&lt;/code&gt; — so it waits on &lt;code&gt;deferred.await&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;replying to Friend A:&lt;/em&gt;&lt;br&gt;
but maybe you could somehow reconfigure the &lt;code&gt;Scheduler&lt;/code&gt; for...&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;and it's also region-scoped, like pretty much everything, btw&lt;br&gt;
so apparently you can customize fiber subtrees&lt;br&gt;
but I haven't worked with it much&lt;br&gt;
only remember you can configure &lt;code&gt;yieldCount&lt;/code&gt;, I think, and schedule fiberinos&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Evangeline Rome:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;replying to Evangeline Rome:&lt;/em&gt;&lt;br&gt;
so:&lt;br&gt;
&lt;/p&gt;


&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nc"&gt;Effect&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;gen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;impl1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;yield&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nc"&gt;Tag1SecToInit&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;return1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;yield&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;impl1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;1secLongCall&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;impl2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;yield&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nc"&gt;Tag2SecToInit&lt;/span&gt;
  &lt;span class="k"&gt;yield&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;impl2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;instantCall&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;return1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pipe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nc"&gt;Effect&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Provide&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;AppLayer&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;so ideally it'd be awesome to have something like this in my case. and that's why I'm suffering with all these Deferreds. I want out-of-the-box tooling for this.&lt;br&gt;
as soon as one second passes: &lt;code&gt;Tag1SecToInit&lt;/code&gt; is built and &lt;code&gt;impl1&lt;/code&gt; is resolved&lt;br&gt;
as soon as the next second passes: &lt;code&gt;impl1.1secLongCall&lt;/code&gt; finishes executing and &lt;code&gt;Tag2SecToInit&lt;/code&gt; is built and &lt;code&gt;impl2&lt;/code&gt; is resolved and the &lt;code&gt;instantCall&lt;/code&gt; method finishes instantly&lt;br&gt;
done in 2 seconds&lt;/p&gt;

&lt;p&gt;while with the current setup, with layers by default&lt;br&gt;
it's first two seconds of waiting to build both of them in parallel, and then one more to wait for the blocking &lt;code&gt;1secLongCall&lt;/code&gt; in the middle of the main effect&lt;/p&gt;

&lt;p&gt;three in total&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;replying to Friend A:&lt;/em&gt;&lt;br&gt;
but maybe you could somehow reconfigure the &lt;code&gt;Scheduler&lt;/code&gt; for...&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I talked to an LLM, didn't see any use for it in my use case. didn't figure out myself either how it could be useful. if someone can explain to me how different scheduling could help within that last code snippet, I'd be glad to listen&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;replying to Friend A:&lt;/em&gt;&lt;br&gt;
yeah, here you could actually use &lt;code&gt;Effectable&lt;/code&gt; so it waits on...&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;oh, that might actually be a good idea btw&lt;/p&gt;

&lt;p&gt;a code example wouldn't hurt if you've got the energy and time right now&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Friend A:&lt;/strong&gt;&lt;br&gt;
no, the scheduler is specifically about operations — you've got a bunch of operations and you can schedule them, pause, prioritize, switch between fibers (yield execution)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Evangeline Rome:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;replying to Friend A:&lt;/em&gt;&lt;br&gt;
I feel like the service availability problem fundamentally can't be...&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;explain what you mean by service availability?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Friend A:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;replying to Evangeline Rome:&lt;/em&gt;&lt;br&gt;
explain what you mean by service availability?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;you launch their construction at startup so they build in parallel with the app starting up&lt;br&gt;
the app is built and the hot code asks for services — and they haven't finished yet — is that your case?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Evangeline Rome:&lt;/strong&gt;&lt;br&gt;
my brain is just dragging backend and SRE terms in here, like availability, and I'm kinda stuck&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;is that your case?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;well yeah, but that's not the whole case, just part of it&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;replying to Friend A:&lt;/em&gt;&lt;br&gt;
yeah, here you could actually use &lt;code&gt;Effectable&lt;/code&gt; so it waits on...&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;so I thought&lt;br&gt;
and it won't help though, will it&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Friend A:&lt;/strong&gt;&lt;br&gt;
I'm sitting here looking at it too)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Evangeline Rome:&lt;/strong&gt;&lt;br&gt;
like&lt;br&gt;
it won't even get to that point&lt;br&gt;
until the layer is built&lt;br&gt;
even &lt;code&gt;Layer.map&lt;/code&gt; is useless&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Friend A:&lt;/strong&gt;&lt;br&gt;
no, well, you have to build the layer the way you did it&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Evangeline Rome:&lt;/strong&gt;&lt;br&gt;
yeah, that's needed&lt;br&gt;
right into the very implementation&lt;br&gt;
right where the layer is getting built&lt;br&gt;
hooking in&lt;br&gt;
because otherwise everything everywhere will wait for that layer's build&lt;br&gt;
or you know what&lt;br&gt;
I think I've got it&lt;br&gt;
make a HOF that maps layers&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;A&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;E&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;R&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;layer&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nc"&gt;Layer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;effect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Effect&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;gen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;deferred&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;yield&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nc"&gt;Deferred&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;make&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Context&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;AddContextInitErrs&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;A&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;E&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;yield&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nc"&gt;Layer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;build&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;layer&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pipe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nc"&gt;Deferred&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;into&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;deferred&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nc"&gt;Effect&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;forkScoped&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Proxy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;whatever&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;this is the thing, btw&lt;br&gt;
and maybe even way fucking cooler than the shit I was fucking around with in the playground I mentioned earlier&lt;br&gt;
or maybe it's complementary&lt;br&gt;
gotta keep playing with it&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Good person B:&lt;/strong&gt;&lt;br&gt;
damn, look at you guys go! 🤓&lt;br&gt;
never get tired of admiring this&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Evangeline Rome:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;replying to Evangeline Rome:&lt;/em&gt;&lt;br&gt;
make a HOF that maps layers &amp;lt;A, E,...&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;but here too it looks like you can catch a shitload of trouble. I don't yet know how to properly weld everything else in there, like an OTel span for building the layer itself, how to attach scopes correctly, how to route nested dependencies&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;replying to Evangeline Rome:&lt;/em&gt;&lt;br&gt;
make a HOF that maps layers &amp;lt;A, E,...&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;that's just pseudocode I banged out in the chat just now&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Friend A:&lt;/strong&gt;&lt;br&gt;
why the proxy?&lt;br&gt;
maybe just put a &lt;code&gt;Deferred&lt;/code&gt; into the context&lt;br&gt;
and when reading, for example, do &lt;code&gt;yield* MyTag.background&lt;/code&gt; — resolve from the &lt;code&gt;Deferred&lt;/code&gt; there&lt;br&gt;
and if it's plain &lt;code&gt;yield* MyTag&lt;/code&gt; — you get a &lt;code&gt;Deferred&amp;lt;MyService, Err&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Evangeline Rome:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;replying to Friend A:&lt;/em&gt;&lt;br&gt;
why the proxy?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;so I don't have to write this crap out by hand&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="n"&gt;currentTime&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Effect&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;flatMap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;deferredAudioContext&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nc"&gt;EAudioContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;currentTime&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="n"&gt;decodeAudioData&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;encodedAudioBuffer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;ArrayBuffer&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
  &lt;span class="nc"&gt;Effect&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;flatMap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;deferredAudioContext&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nc"&gt;EAudioContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;decodeAudioData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;encodedAudioBuffer&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;you can generate it. either on individual values of the context container (the service implementations), or on all of them at once&lt;br&gt;
to create on the fly those very effects that people will await&lt;br&gt;
to push it even further away, until the ACTUAL use of the methods&lt;br&gt;
because again&lt;br&gt;
why freeze&lt;br&gt;
if you're only using one method in some handler that's called on some event, like a click on a particular button&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;replying to Evangeline Rome:&lt;/em&gt;&lt;br&gt;
so I don't have to write this crap by hand...&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;so like class static accessors, just in a different situation&lt;/p&gt;

&lt;p&gt;for class static accessors you can use a proxy too&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Friend A:&lt;/strong&gt;&lt;br&gt;
gotcha, maybe it can be split into two tasks&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Evangeline Rome:&lt;/strong&gt;&lt;br&gt;
well, maybe&lt;br&gt;
it's just that in my use case I'll only be using one anyway&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;replying to Evangeline Rome:&lt;/em&gt;&lt;br&gt;
make a HOF that maps layers...&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;in general yeah&lt;br&gt;
I originally meant putting the proxy in a bit deeper&lt;br&gt;
imagine like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;mapSome&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;tag&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;impl&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;tag&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;specific&lt;/span&gt;
    &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="nc"&gt;Option&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;some&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Proxy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;impl&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Option&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;none&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;aaah&lt;br&gt;
fuck&lt;br&gt;
yeah&lt;br&gt;
well, with &lt;code&gt;Deferred&lt;/code&gt; that gets a bit more complicated&lt;br&gt;
but that's the principle, yeah&lt;br&gt;
it'll be a complex proxy&lt;br&gt;
but totally doable&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;replying to Evangeline Rome:&lt;/em&gt;&lt;br&gt;
specifically at this: &lt;code&gt;currentTime&lt;/code&gt;:...&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;the plan is to immediately create such a magical context object that, when its keys get materialized, hands out values that are again proxies, which on each individual method add this kind of mapping with the &lt;code&gt;Deferred&lt;/code&gt;&lt;br&gt;
complications might start with how it plays with composition with other layers, like through &lt;code&gt;Layer.map&lt;/code&gt; or &lt;code&gt;Layer.merge&lt;/code&gt;&lt;br&gt;
gotta play with this seriously&lt;/p&gt;

&lt;p&gt;PS&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The laziest article I've ever written. It still makes complete sense. Used AI to translate from the native language where the conversation happened into English. The translation is fully validated. The format is inspired by Ink and Switch's article called "&lt;a href="https://www.inkandswitch.com/tangents/artificial/" rel="noopener noreferrer"&gt;Artificial&lt;/a&gt;".&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>effect</category>
      <category>effectts</category>
      <category>webdev</category>
      <category>frontend</category>
    </item>
  </channel>
</rss>
