FuncType - v0.8.85
    Preparing search index...

    Interface RefType<A>

    A mutable reference container that holds a value of type A. This provides controlled mutability in a functional context.

    const counter = Ref(0)
    counter.get() // 0
    counter.set(5)
    counter.get() // 5
    counter.update(n => n + 1)
    counter.get() // 6
    interface RefType<A> {
        constructor: any;
        of: typeof RefType;
        compareAndSet(expected: A, newValue: A): boolean;
        get(): A;
        getAndSet(value: A): A;
        getAndUpdate(f: (current: A) => A): A;
        modify<B>(f: (current: A) => [A, B]): B;
        set(value: A): void;
        update(f: (current: A) => A): void;
        updateAndGet(f: (current: A) => A): A;
    }

    Type Parameters

    • A
    Index

    Constructors

    constructor: any

    Properties

    of: typeof RefType

    Methods

    • Compare and swap - only updates if current value equals expected

      Parameters

      • expected: A
      • newValue: A

      Returns boolean

    • Get the current value

      Returns A

    • Update and return the old value

      Parameters

      • value: A

      Returns A

    • Update and return the old value

      Parameters

      • f: (current: A) => A

      Returns A

    • Modify the value and return a result

      Type Parameters

      • B

      Parameters

      • f: (current: A) => [A, B]

      Returns B

    • Set a new value

      Parameters

      • value: A

      Returns void

    • Update the value using a function

      Parameters

      • f: (current: A) => A

      Returns void

    • Update and return the new value

      Parameters

      • f: (current: A) => A

      Returns A