Hyperlinkv0.8.0-beta.28

Ref

Ref.makeUnsafeconsteffect/Ref.ts:156
<A>(value: A): Ref<A>

Creates a new Ref with the specified initial value (unsafe version).

When to use

Use when you need immediate synchronous construction and can guarantee that creating the Ref outside of Effect is safe.

Gotchas

Prefer Ref.make for Effect-wrapped creation in Effect programs.

Example (Creating a ref unsafely)

import { Ref } from "effect"

// Create a ref directly without Effect
const counter = Ref.makeUnsafe(0)

// Get the current value
const value = Ref.getUnsafe(counter)
console.log(value) // 0

// Note: This is unsafe and should be used carefully
// Prefer Ref.make for Effect-wrapped creation
constructors
Source effect/Ref.ts:1565 lines
export const makeUnsafe = <A>(value: A): Ref<A> => {
  const self = Object.create(RefProto)
  self.ref = MutableRef.make(value)
  return self
}
Referenced by 2 symbols