Shared

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

A wire that produces a reference-counted shared instance via Resource.shared.

The underlying instance may be shared across multiple allocating scopes. A reference count tracks usage, and the instance is released when the last referencing scope is closed. This is the default wire type produced by shared[T].

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 true since this is a shared wire.

Returns true since this is a shared wire.

Attributes

Returns

always true for shared 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]

Returns this wire since it is already shared.

Returns this wire since it is already shared.

Attributes

Returns

this wire unchanged

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 Out values with memoization

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

Converts this shared wire to a unique wire.

Converts this shared wire to a unique wire.

Attributes

Returns

a new unique wire with the same construction function

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