MCPcopy Index your code
hub / github.com/tinyplex/tinybase / useGoToCallback

Function useGoToCallback

src/ui-react/hooks.ts:2232–2252  ·  view source on GitHub ↗
(
  getCheckpointId: (parameter: Parameter) => Id,
  getCheckpointIdDeps: DependencyList = EMPTY_ARRAY,
  checkpointsOrCheckpointsId?: CheckpointsOrCheckpointsId,
  then: (checkpoints: Checkpoints, checkpointId: Id) => void = getUndefined,
  thenDeps: DependencyList = EMPTY_ARRAY,
)

Source from the content-addressed store, hash-verified

2230): Callback => useCheckpointAction(checkpointsOrCheckpointsId, 'goForward');
2231
2232export const useGoToCallback: typeof useGoToCallbackDecl = <Parameter>(
2233 getCheckpointId: (parameter: Parameter) => Id,
2234 getCheckpointIdDeps: DependencyList = EMPTY_ARRAY,
2235 checkpointsOrCheckpointsId?: CheckpointsOrCheckpointsId,
2236 then: (checkpoints: Checkpoints, checkpointId: Id) => void = getUndefined,
2237 thenDeps: DependencyList = EMPTY_ARRAY,
2238): ParameterizedCallback<Parameter> => {
2239 const checkpoints = useCheckpointsOrCheckpointsById(
2240 checkpointsOrCheckpointsId,
2241 );
2242 return useCallback(
2243 (parameter) =>
2244 ifNotUndefined(checkpoints, (checkpoints) =>
2245 ifNotUndefined(getCheckpointId(parameter as any), (checkpointId: Id) =>
2246 then(checkpoints.goTo(checkpointId), checkpointId),
2247 ),
2248 ),
2249 // eslint-disable-next-line react-hooks/exhaustive-deps
2250 [checkpoints, ...getCheckpointIdDeps, ...thenDeps],
2251 );
2252};
2253
2254export const useUndoInformation: typeof useUndoInformationDecl = (
2255 checkpointsOrCheckpointsId?: CheckpointsOrCheckpointsId,

Callers 3

TestFunction · 0.90
CheckpointsFunction · 0.50
CheckpointsFunction · 0.50

Calls 2

goToMethod · 0.65

Tested by 1

TestFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…