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

Function useAddRowCallback

src/ui-solid/primitives.ts:767–797  ·  view source on GitHub ↗
(
  tableId: MaybeAccessor<Id> | GetId<Parameter>,
  getRow: (parameter: Parameter, store: Store) => Row,
  storeOrStoreId?: MaybeAccessor<StoreOrStoreId | undefined>,
  then: (
    rowId: MaybeAccessor<Id> | undefined,
    store: Store,
    row: Row,
  ) => void = getUndefined,
  reuseRowIds = true,
)

Source from the content-addressed store, hash-verified

765 useStoreSetCallback(storeOrStoreId, ROW, getRow, then, tableId, rowId);
766
767export const useAddRowCallback = <Parameter>(
768 tableId: MaybeAccessor<Id> | GetId<Parameter>,
769 getRow: (parameter: Parameter, store: Store) => Row,
770 storeOrStoreId?: MaybeAccessor<StoreOrStoreId | undefined>,
771 then: (
772 rowId: MaybeAccessor<Id> | undefined,
773 store: Store,
774 row: Row,
775 ) => void = getUndefined,
776 reuseRowIds = true,
777): ParameterizedCallback<Parameter> => {
778 const store = useStoreOrStoreById(storeOrStoreId);
779 return (parameter) =>
780 ifNotUndefined(getThing(store), (resolvedStore) =>
781 ifNotUndefined(
782 getRow(parameter as Parameter, resolvedStore),
783 (row: Row) =>
784 then(
785 resolvedStore.addRow(
786 isFunction(tableId)
787 ? tableId(parameter as Parameter, resolvedStore)
788 : tableId,
789 row,
790 reuseRowIds,
791 ),
792 resolvedStore,
793 row,
794 ),
795 ),
796 );
797};
798
799export const useSetPartialRowCallback = <Parameter>(
800 tableId: MaybeAccessor<Id> | GetId<Parameter>,

Callers 2

WriterFunction · 0.90
primitives.test.tsFile · 0.90

Calls 6

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

Tested by 1

WriterFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…