Unique

zio.blocks.scope.Wire.Unique
See theUnique companion object
final case class Unique[-In, +Out](makeFn: (Scope, Context[In]) => Out) extends Wire[In, Out]

A wire that produces a fresh instance each time it's used.

Unlike shared wires, unique wires create new instances for each dependent service. Use for services that should not be shared, like request-scoped resources or per-call state.

Type parameters

In

the dependencies required to construct the service

Out

the service type produced

Value parameters

makeFn

the function that constructs the service given a finalizer and context

Attributes

Companion
object
Source
Wire.scala
Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait Wire[In, Out]
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def isShared: Boolean

Returns false since this is a unique wire.

Returns false since this is a unique wire.

Attributes

Returns

always false for unique wires

Source
Wire.scala
def make(scope: Scope, ctx: Context[In]): Out

Constructs the service using the given scope and context.

Constructs the service using the given scope and context.

Value parameters

ctx

the context providing dependencies

scope

the scope for cleanup registration

Attributes

Returns

the constructed service

Source
Wire.scala
def shared: Shared[In, Out]

Converts this unique wire to a shared wire.

Converts this unique wire to a shared wire.

Attributes

Returns

a new shared wire with the same construction function

Source
Wire.scala
def toResource(deps: Context[In]): Resource[Out]

Converts this Wire to a Resource by providing resolved dependencies.

Converts this Wire to a Resource by providing resolved dependencies.

Value parameters

deps

Context containing all required dependencies

Attributes

Returns

a Resource that creates fresh Out values on each use

Source
Wire.scala
def unique: Unique[In, Out]

Returns this wire since it is already unique.

Returns this wire since it is already unique.

Attributes

Returns

this wire unchanged

Source
Wire.scala

Inherited methods

final def isUnique: Boolean

Returns true if this wire is unique (creates fresh instances each time).

Returns true if this wire is unique (creates fresh instances each time).

Unique wires create a new instance for each dependent service.

Attributes

Returns

true if this wire is unique, false if shared

Inherited from:
Wire
Source
Wire.scala
def productElementNames: Iterator[String]

An iterator over the names of all the elements of this product.

An iterator over the names of all the elements of this product.

Attributes

Inherited from:
Product
Source
Product.scala
def productIterator: Iterator[Any]

An iterator over all the elements of this product.

An iterator over all the elements of this product.

Attributes

Returns

in the default implementation, an Iterator[Any]

Inherited from:
Product
Source
Product.scala