@@ -9,24 +9,26 @@ import { Bus } from "../bus"
99import { Command } from "../command"
1010import { Instance } from "./instance"
1111import { Log } from "@/util/log"
12- import { BootstrapRuntime } from "@/effect/bootstrap-runtime"
1312import { FileWatcher } from "@/file/watcher"
1413import { ShareNext } from "@/share/share-next"
14+ import * as Effect from "effect/Effect"
1515
16- export async function InstanceBootstrap ( ) {
16+ export const InstanceBootstrap = Effect . gen ( function * ( ) {
1717 Log . Default . info ( "bootstrapping" , { directory : Instance . directory } )
18- await Plugin . init ( )
19- void BootstrapRuntime . runPromise ( ShareNext . Service . use ( ( svc ) => svc . init ( ) ) )
20- void BootstrapRuntime . runPromise ( Format . Service . use ( ( svc ) => svc . init ( ) ) )
21- await LSP . init ( )
22- File . init ( )
23- void BootstrapRuntime . runPromise ( FileWatcher . Service . use ( ( svc ) => svc . init ( ) ) )
24- Vcs . init ( )
25- Snapshot . init ( )
18+ yield * Plugin . Service . use ( ( svc ) => svc . init ( ) )
19+ yield * ShareNext . Service . use ( ( svc ) => svc . init ( ) ) . pipe ( Effect . forkDetach )
20+ yield * Format . Service . use ( ( svc ) => svc . init ( ) ) . pipe ( Effect . forkDetach )
21+ yield * LSP . Service . use ( ( svc ) => svc . init ( ) )
22+ yield * File . Service . use ( ( svc ) => svc . init ( ) ) . pipe ( Effect . forkDetach )
23+ yield * FileWatcher . Service . use ( ( svc ) => svc . init ( ) ) . pipe ( Effect . forkDetach )
24+ yield * Vcs . Service . use ( ( svc ) => svc . init ( ) ) . pipe ( Effect . forkDetach )
25+ yield * Snapshot . Service . use ( ( svc ) => svc . init ( ) ) . pipe ( Effect . forkDetach )
2626
27- Bus . subscribe ( Command . Event . Executed , async ( payload ) => {
28- if ( payload . properties . name === Command . Default . INIT ) {
29- Project . setInitialized ( Instance . project . id )
30- }
31- } )
32- }
27+ yield * Bus . Service . use ( ( svc ) =>
28+ svc . subscribeCallback ( Command . Event . Executed , async ( payload ) => {
29+ if ( payload . properties . name === Command . Default . INIT ) {
30+ Project . setInitialized ( Instance . project . id )
31+ }
32+ } ) ,
33+ )
34+ } ) . pipe ( Effect . withSpan ( "InstanceBootstrap" ) )
0 commit comments