Package: effect
Module: MutableRef
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
Signature
declare const get: <T>(self: MutableRef<T>) => T
Since v2.0.0