Aller au contenu principal

Ref

Index

Accessor

modify

  • modify<Value>(ref: Ref<Value>, mapFn: (current: Value) => Value): void
  • Change the current value using a mapping function that returns the new value

    @example
    const ref = Ref('foo');
    Ref.modify(ref, (current) => current + 'bar'); // Ref.read(ref) == 'foobar'

    Type parameters

    • Value

read

  • read<Value>(ref: Ref<Value>): Value
  • Returns the current ref value

    @example
    const ref = Ref('foo');
    Ref.read(ref); // 'foo'

    Type parameters

    • Value

write

  • write<Value>(ref: Ref<Value>, newValue: Value): void
  • Change the current value

    @example
    const ref = Ref('foo');
    Ref.write(ref, 'bar'); // Ref.read(ref) == 'bar'

    Type parameters

    • Value

Type

hasInstance

  • hasInstance(anyValue: unknown): anyValue is Ref<unknown>
  • Returns true when anyValue has a current property

    @example
    Ref.hasInstance(Ref(123)) // true
    Ref.hasInstance(null)) // false

Other

constcurrent

current: current = 'current'

Current value symbol

Page Options