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

Function useAddRowCallback

src/ui-react/hooks.ts:970–998  ·  view source on GitHub ↗
(
  tableId: Id | GetId<Parameter>,
  getRow: (parameter: Parameter, store: Store) => Row,
  getRowDeps: DependencyList = EMPTY_ARRAY,
  storeOrStoreId?: StoreOrStoreId,
  then: (rowId: Id | undefined, store: Store, row: Row) => void = getUndefined,
  thenDeps: DependencyList = EMPTY_ARRAY,
  reuseRowIds = true,
)

Source from the content-addressed store, hash-verified

968 );
969
970export const useAddRowCallback: typeof useAddRowCallbackDecl = <Parameter>(
971 tableId: Id | GetId<Parameter>,
972 getRow: (parameter: Parameter, store: Store) => Row,
973 getRowDeps: DependencyList = EMPTY_ARRAY,
974 storeOrStoreId?: StoreOrStoreId,
975 then: (rowId: Id | undefined, store: Store, row: Row) => void = getUndefined,
976 thenDeps: DependencyList = EMPTY_ARRAY,
977 reuseRowIds = true,
978): ParameterizedCallback<Parameter> => {
979 const store = useStoreOrStoreById(storeOrStoreId);
980 return useCallback(
981 (parameter) =>
982 ifNotUndefined(store, (store) =>
983 ifNotUndefined(getRow(parameter as any, store), (row: Row) =>
984 then(
985 store.addRow(
986 isFunction(tableId) ? tableId(parameter as any, store) : tableId,
987 row,
988 reuseRowIds,
989 ),
990 store,
991 row,
992 ),
993 ),
994 ),
995 // eslint-disable-next-line react-hooks/exhaustive-deps
996 [store, tableId, ...getRowDeps, ...thenDeps, reuseRowIds],
997 );
998};
999
1000export const useSetPartialRowCallback: typeof useSetPartialRowCallbackDecl = <
1001 Parameter,

Callers 4

WriterFunction · 0.90
TestFunction · 0.90
SettersFunction · 0.50
SettersFunction · 0.50

Calls 5

useStoreOrStoreByIdFunction · 0.90
isFunctionFunction · 0.90
addRowMethod · 0.65
getRowFunction · 0.50
tableIdFunction · 0.50

Tested by 2

WriterFunction · 0.72
TestFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…