(
initial: Value,
options: {
readonly differ: Differ.Differ<Value, Patch>
readonly fork: Patch
readonly join?: ((oldV: Value, newV: Value) => Value) | undefined
}
)
| 1982 | |
| 1983 | /** @internal */ |
| 1984 | export const fiberRefUnsafeMakePatch = <Value, Patch>( |
| 1985 | initial: Value, |
| 1986 | options: { |
| 1987 | readonly differ: Differ.Differ<Value, Patch> |
| 1988 | readonly fork: Patch |
| 1989 | readonly join?: ((oldV: Value, newV: Value) => Value) | undefined |
| 1990 | } |
| 1991 | ): FiberRef.FiberRef<Value> => { |
| 1992 | const _fiberRef = { |
| 1993 | ...CommitPrototype, |
| 1994 | [FiberRefTypeId]: fiberRefVariance, |
| 1995 | initial, |
| 1996 | commit() { |
| 1997 | return fiberRefGet(this) |
| 1998 | }, |
| 1999 | diff: (oldValue: Value, newValue: Value) => options.differ.diff(oldValue, newValue), |
| 2000 | combine: (first: Patch, second: Patch) => options.differ.combine(first, second), |
| 2001 | patch: (patch: Patch) => (oldValue: Value) => options.differ.patch(patch, oldValue), |
| 2002 | fork: options.fork, |
| 2003 | join: options.join ?? ((_, n) => n) |
| 2004 | } |
| 2005 | return _fiberRef |
| 2006 | } |
| 2007 | |
| 2008 | /** @internal */ |
| 2009 | export const fiberRefUnsafeMakeRuntimeFlags = ( |
no test coverage detected
searching dependent graphs…