On this pageRef Index AccessormodifyreadwriteTypehasInstanceOthercurrentpropertyAccessor modifymodify<Value>(self, mapFn): voidChange the current value using a mapping function that returns the new value@exampleconst ref = Ref('foo');Ref.modify(ref, (current) => current + 'bar'); // Ref.read(ref) == 'foobar'readread<Value>(self): ValueReturns the current ref value@exampleconst ref = Ref('foo');Ref.read(ref); // 'foo'writewrite<Value>(self, newValue): voidChange the current value@exampleconst ref = Ref('foo');Ref.write(ref, 'bar'); // Ref.read(ref) == 'bar'Type hasInstancehasInstance(anyValue): anyValue is Ref<unknown>Returns true when anyValue has a current property@exampleRef.hasInstance(Ref(123)) // trueRef.hasInstance(null)) // falseOther currentcurrent: current = ...Current value symbolpropertyproperty<T, Name>(self, propertyName): Ref<T[Name]>@exampleconst parent = Ref({ foo: true });const child = Ref.property(parent, 'foo');// Ref { current: true }
Change the current value using a mapping function that returns the new value