effex-monorepo
    Preparing search index...

    Variable Ref

    Ref: { make: <A>() => Effect<Ref<A>, never, Scope> }

    Ref module namespace for creating mutable references.

    Type Declaration

    • make: <A>() => Effect<Ref<A>, never, Scope>

      Create a Ref to hold a mutable reference to a value.

      // For DOM elements
      const inputRef = yield* Ref.make<HTMLInputElement>()

      // Later, focus the input
      yield* inputRef.value.pipe(
      Effect.tap((el) => Effect.sync(() => el.focus()))
      )

      // For any value
      const cleanupRef = yield* Ref.make<() => void>()
      cleanupRef.current = () => console.log("cleanup")