Skip to main content

Ref

Index

Accessor

modify

  • modify<Value>(self, mapFn): 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'

read

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

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

write

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

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

Type

hasInstance

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

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

Other

current

current: current = ...

Current value symbol

property

  • property<T, Name>(self, propertyName): Ref<T[Name]>
  • @example
    const parent = Ref({ foo: true });
    const child = Ref.property(parent, 'foo');// Ref { current: true }