Add Effect v4 support, Fast Refresh tooling, and revamped docs #56
@@ -11,7 +11,7 @@ export interface ScopeRegistryService {
|
||||
commit(key: ScopeRegistryService.Key): Effect.Effect<ScopeRegistryService.Entry, Cause.NoSuchElementError>
|
||||
release(key: ScopeRegistryService.Key): Effect.Effect<ScopeRegistryService.Entry, Cause.NoSuchElementError>
|
||||
|
||||
readonly run: Effect.Effect<void>
|
||||
readonly run: Effect.Effect<void, never, Scope.Scope>
|
||||
}
|
||||
|
||||
export declare namespace ScopeRegistryService {
|
||||
@@ -81,19 +81,20 @@ export class ScopeRegistryServiceImpl implements ScopeRegistryService {
|
||||
)
|
||||
}
|
||||
|
||||
get run(): Effect.Effect<void> {
|
||||
return SubscriptionRef.changes(this.ref).pipe(
|
||||
Stream.switchMap(entries => Option.match(this.getNextExpiration(entries), {
|
||||
onNone: () => Stream.never,
|
||||
onSome: expiresAt => Stream.fromEffect(DateTime.now.pipe(
|
||||
Effect.flatMap(now => DateTime.isLessThan(now, expiresAt)
|
||||
? Effect.sleep(DateTime.distance(now, expiresAt))
|
||||
: Effect.void),
|
||||
Effect.andThen(Effect.uninterruptible(this.closeExpired)),
|
||||
)),
|
||||
})),
|
||||
Stream.runDrain,
|
||||
Effect.ensuring(this.dispose),
|
||||
get run(): Effect.Effect<void, never, Scope.Scope> {
|
||||
return Effect.addFinalizer(() => this.dispose).pipe(
|
||||
Effect.andThen(SubscriptionRef.changes(this.ref).pipe(
|
||||
Stream.switchMap(entries => Option.match(this.getNextExpiration(entries), {
|
||||
onNone: () => Stream.never,
|
||||
onSome: expiresAt => Stream.fromEffect(DateTime.now.pipe(
|
||||
Effect.flatMap(now => DateTime.isLessThan(now, expiresAt)
|
||||
? Effect.sleep(DateTime.distance(now, expiresAt))
|
||||
: Effect.void),
|
||||
Effect.andThen(Effect.uninterruptible(this.closeExpired)),
|
||||
)),
|
||||
})),
|
||||
Stream.runDrain,
|
||||
)),
|
||||
this.runSemaphore.withPermit,
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user