final class Local[A] extends LocalDeprecated[A]
A Local is a ThreadLocal whose scope is flexible. The state
of all Locals may be saved or restored onto the current thread by
the user. This is useful for threading Locals through execution
contexts.
Because it's not meaningful to inherit control from two places, Locals don't have to worry about having to merge two contexts.
Note: the implementation is optimized for situations in which save and restore optimizations are dominant.
- Source
- Local.scala
- Alphabetic
- By Inheritance
- Local
- LocalDeprecated
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new Local(default: () => A)
Value Members
- def :=(value: A): Unit
Alis for update.
- def apply(): A
Returns the current value of this
Local. - def bind[R](value: A)(f: => R)(implicit R: CanBindLocals[R]): R
Execute a block with a specific local value, restoring the current state upon completion.
Execute a block with a specific local value, restoring the current state upon completion.
The implementation uses the CanBindLocals type class because in case of asynchronous data types that should be waited on, like
FutureorCompletableFuture, then the locals context also needs to be cleared on the future's completion, for correctness. - def bindClear[R](f: => R)(implicit R: CanBindLocals[R]): R
Execute a block with the
Localcleared, restoring the current state upon completion.Execute a block with the
Localcleared, restoring the current state upon completion.The implementation uses the CanBindLocals type class because in case of asynchronous data types that should be waited on, like
FutureorCompletableFuture, then the locals context also needs to be cleared on the future's completion, for correctness. - def clear(): Unit
Clear the Local's value.
Clear the Local's value. Other Locals are not modified.
General usage should be in Local.isolate to avoid leaks.
- def get: A
Alias for apply.
- val key: Key
- def update(value: A): Unit
Updates the value of this
Local. - def value: Option[A]
Returns the current value of this
Local, orNonein case this local should fallback to the default.Returns the current value of this
Local, orNonein case this local should fallback to the default.Use apply in case automatic fallback is needed.
- def value_=(update: Option[A]): Unit
Updates the current value of this
Local.

This is the API documentation for the Monix library.
Package Overview
monix.execution exposes lower level primitives for dealing with asynchronous execution:
Atomictypes, as alternative tojava.util.concurrent.atomicmonix.catnap exposes pure abstractions built on top of the Cats-Effect type classes:
monix.eval is for dealing with evaluation of results, thus exposing Task and Coeval.
monix.reactive exposes the
Observablepattern:Observableimplementationsmonix.tail exposes Iterant for purely functional pull based streaming:
BatchandBatchCursor, the alternatives to Scala'sIterableandIteratorrespectively that we are using within Iterant's encodingYou can control evaluation with type you choose - be it Task, Coeval, cats.effect.IO or your own as long as you provide correct cats-effect or cats typeclass instance.