Hyperlinkv0.8.0-beta.28

MutableRef

MutableRef.getconsteffect/MutableRef.ts:281
<T>(self: MutableRef<T>): T

Gets the current value of the MutableRef.

When to use

Use to read the current MutableRef value without mutating it.

Example (Reading current values)

import { MutableRef } from "effect"

const ref = MutableRef.make("hello")
console.log(MutableRef.get(ref)) // "hello"

MutableRef.set(ref, "world")
console.log(MutableRef.get(ref)) // "world"

// Reading complex objects
const config = MutableRef.make({ port: 3000, host: "localhost" })
const currentConfig = MutableRef.get(config)
console.log(currentConfig.port) // 3000

// Multiple reads return the same value
const value1 = MutableRef.get(ref)
const value2 = MutableRef.get(ref)
console.log(value1 === value2) // true
general
export const get = <T>(self: MutableRef<T>): T => self.current
Referenced by 5 symbols