Hyperlinkv0.8.0-beta.28

Context

Context.makeUnsafeconsteffect/Context.ts:494
<Services = never>(mapUnsafe: ReadonlyMap<string, any>): Context<Services>

Creates a Context from an existing service map.

When to use

Use when constructing a low-level Context from a trusted map whose lifecycle you control.

Gotchas

This is unsafe because later mutation of the provided map can affect the created Context. Prefer empty, make, add, or merge for normal Context construction.

Example (Creating a context from a map)

import { Context } from "effect"

// Create a context from a Map (unsafe)
const map = new Map([
  ["Logger", { log: (msg: string) => console.log(msg) }]
])

const context = Context.makeUnsafe(map)
constructors
Source effect/Context.ts:4946 lines
export const makeUnsafe = <Services = never>(mapUnsafe: ReadonlyMap<string, any>): Context<Services> => {
  const self = Object.create(Proto)
  self.mapUnsafe = mapUnsafe
  self.mutable = false
  return self
}
Referenced by 7 symbols