d dependencies v0.1.0
Docs menu
API Scope

Scope

Scope tracks finalizers for scoped dependencies.

import { Scope } from '@fuiste/dependencies'

Create

const scope = Scope.make()

Add Finalizers

Scope.addFinalizer(scope, async () => {
  await release()
})

Normally Dependency.scoped registers finalizers for you. Manual finalizers are useful in adapters or tests.

Close

await Scope.close(scope)

Finalizers run in reverse registration order. Closing an already closed scope is a no-op.

If one finalizer fails, close throws that error. If several fail, it throws an aggregate Error with an errors property.

Runtime Check

Scope.isScope(value)

Use it when accepting unknown values at a boundary.