@w5s/coreNamespacesRefSur cette pageRef Index AccessormodifyreadwriteTypehasInstanceOthercurrentAccessor modifymodify<Value>(ref: Ref<Value>, mapFn: (current: Value) => Value): 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'Type parametersValuereadread<Value>(ref: Ref<Value>): ValueReturns the current ref value@exampleconst ref = Ref('foo');Ref.read(ref); // 'foo'Type parametersValuewritewrite<Value>(ref: Ref<Value>, newValue: Value): voidChange the current value@exampleconst ref = Ref('foo');Ref.write(ref, 'bar'); // Ref.read(ref) == 'bar'Type parametersValueType hasInstancehasInstance(anyValue: unknown): anyValue is Ref<unknown>Returns true when anyValue has a current property@exampleRef.hasInstance(Ref(123)) // trueRef.hasInstance(null)) // falseOther constcurrentcurrent: current = 'current'Current value symbol
Change the current value using a mapping function that returns the new value