Packages

object Local extends LocalCompanionDeprecated

Source
Local.scala
Linear Supertypes
LocalCompanionDeprecated, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Local
  2. LocalCompanionDeprecated
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Type Members

  1. sealed abstract class Context extends AnyRef

    Represents the current state of all locals for a given execution context.

    Represents the current state of all locals for a given execution context.

    This should be treated as an opaque value and direct modifications and access are considered verboten.

  2. final class Key extends Serializable

    Internal — key type used in Context.

Value Members

  1. def apply[A](default: A): Local[A]

    Builds a new Local with the given default to be returned if a value hasn't been set, or after the local gets cleared.

    Builds a new Local with the given default to be returned if a value hasn't been set, or after the local gets cleared.

    val num = Local(0)
    num() //=> 0
    
    num := 100
    num() //=> 100
    
    num.clear()
    num() //=> 0
  2. def bind[R](ctx: Context)(f: => R)(implicit R: CanBindLocals[R]): R

    Execute a block of code using the specified state of Local.Context and restore the current state when complete.

    Execute a block of code using the specified state of Local.Context and restore the current state when complete.

    The implementation uses the CanBindLocals type class because in case of asynchronous data types that should be waited on, like Future or CompletableFuture, then the locals context also needs to be cleared on the future's completion, for correctness.

    There's no default instance for synchronous actions available in scope. If you need to work with synchronous actions, you need to import it explicitly:

    import monix.execution.misc.CanBindLocals.Implicits.synchronousAsDefault
  3. def bindClear[R](f: => R)(implicit R: CanBindLocals[R]): R

    Execute a block of code with a clear state of Local.Context and restore the current state when complete.

    Execute a block of code with a clear state of Local.Context and restore the current state when complete.

    The implementation uses the CanBindLocals type class because in case of asynchronous data types that should be waited on, like Future or CompletableFuture, then the locals context also needs to be cleared on the future's completion, for correctness.

    There's no default instance for synchronous actions available in scope. If you need to work with synchronous actions, you need to import it explicitly:

    import monix.execution.misc.CanBindLocals.Implicits.synchronousAsDefault
  4. def clearContext(): Unit

    Clear the Local state.

  5. def closed[R](fn: () => R)(implicit R: CanBindLocals[R]): () => R

    Convert a closure () => R into another closure of the same type whose Local.Context is saved when calling closed and restored upon invocation.

  6. def getContext(): Context

    Return the state of the current Local state.

  7. def isolate[R](f: => R)(implicit R: CanBindLocals[R]): R

    Execute a block of code without propagating any Local.Context changes outside.

    Execute a block of code without propagating any Local.Context changes outside.

    The implementation uses the CanBindLocals type class because in case of asynchronous data types that should be waited on, like Future or CompletableFuture, then the locals context also needs to be cleared on the future's completion, for correctness.

    There's no default instance for synchronous actions available in scope. If you need to work with synchronous actions, you need to import it explicitly:

    import monix.execution.misc.CanBindLocals.Implicits.synchronousAsDefault
  8. def newContext(): Context

    Creates a new, empty Context.

  9. def setContext(ctx: Context): Unit

    Restore the Local state to a given Context.

Deprecated Value Members

  1. def closed[R](fn: () => R): () => R

    DEPRECATED — switch to local.closed[R: CanIsolate].

    DEPRECATED — switch to local.closed[R: CanIsolate].

    Definition Classes
    LocalCompanionDeprecated
    Annotations
    @deprecated
    Deprecated

    (Since version 3.0.0) Switch to local.closed[R: CanIsolate]

  2. def defaultContext(): Unbound

    DEPRECATED — switch to Local.newContext.

    DEPRECATED — switch to Local.newContext.

    Definition Classes
    LocalCompanionDeprecated
    Annotations
    @deprecated
    Deprecated

    (Since version 3.0.0) Renamed to Local.newContext