@livestore/react 0.3.0-dev.22 → 0.3.0-dev.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -38,7 +38,7 @@ Vitest.describe('useRow', () => {
38
38
  expect(result.current.state.username).toBe('')
39
39
  expect(renderCount.val).toBe(1)
40
40
  expect(store.reactivityGraph.getSnapshot({ includeResults: true })).toMatchSnapshot()
41
- store.mutate(tables.userInfo.insert({ id: 'u2', username: 'username_u2' }))
41
+ store.commit(tables.userInfo.insert({ id: 'u2', username: 'username_u2' }))
42
42
 
43
43
  rerender('u2')
44
44
 
@@ -96,7 +96,7 @@ Vitest.describe('useRow', () => {
96
96
  expect(renderCount.val).toBe(1)
97
97
 
98
98
  ReactTesting.act(() =>
99
- store.mutate(tables.userInfo.update({ where: { id: 'u1' }, values: { username: 'username_u1_hello' } })),
99
+ store.commit(tables.userInfo.update({ where: { id: 'u1' }, values: { username: 'username_u1_hello' } })),
100
100
  )
101
101
 
102
102
  expect(result.current.state.id).toBe('u1')
@@ -155,7 +155,7 @@ Vitest.describe('useRow', () => {
155
155
  expect(renderCount.val).toBe(1)
156
156
 
157
157
  ReactTesting.act(() =>
158
- store.mutate(
158
+ store.commit(
159
159
  LiveStore.rawSqlMutation({
160
160
  sql: LiveStore.sql`INSERT INTO todos (id, text, completed) VALUES ('t1', 'buy milk', 0)`,
161
161
  }),
@@ -175,7 +175,7 @@ Vitest.describe('useRow', () => {
175
175
  expect(renderResult.getByRole('current-id').innerHTML).toMatchInlineSnapshot('"Current Task Id: t1"')
176
176
 
177
177
  ReactTesting.act(() =>
178
- store.mutate(
178
+ store.commit(
179
179
  LiveStore.rawSqlMutation({
180
180
  sql: LiveStore.sql`INSERT INTO todos (id, text, completed) VALUES ('t2', 'buy eggs', 0)`,
181
181
  }),
@@ -195,7 +195,7 @@ Vitest.describe('useRow', () => {
195
195
  Effect.gen(function* () {
196
196
  const { store, wrapper, renderCount } = yield* makeTodoMvcReact({})
197
197
 
198
- store.mutate(
198
+ store.commit(
199
199
  todos.insert({ id: 't1', text: 'buy milk', completed: false }),
200
200
  todos.insert({ id: 't2', text: 'buy bread', completed: false }),
201
201
  )
@@ -220,7 +220,7 @@ Vitest.describe('useRow', () => {
220
220
  { wrapper, initialProps: 'u1' },
221
221
  )
222
222
 
223
- ReactTesting.act(() => store.mutate(tables.userInfo.insert({ id: 'u2', username: 'username_u2', text: 'milk' })))
223
+ ReactTesting.act(() => store.commit(tables.userInfo.insert({ id: 'u2', username: 'username_u2', text: 'milk' })))
224
224
 
225
225
  expect(result.current.todos.length).toBe(2)
226
226
  expect(renderCount.val).toBe(1)
@@ -274,7 +274,7 @@ Vitest.describe('useRow', () => {
274
274
 
275
275
  // For u2 we'll make sure that the row already exists,
276
276
  // so the lazy `insert` will be skipped
277
- ReactTesting.act(() => store.mutate(tables.userInfo.insert({ id: 'u2', username: 'username_u2' })))
277
+ ReactTesting.act(() => store.commit(tables.userInfo.insert({ id: 'u2', username: 'username_u2' })))
278
278
 
279
279
  rerender('u2')
280
280
 
package/src/useRow.ts CHANGED
@@ -138,11 +138,11 @@ export const useRow: {
138
138
 
139
139
  // NOTE we need to account for the short-hand syntax for single-column+singleton tables
140
140
  if (table.options.isSingleton) {
141
- store.mutate(table.update(newValue))
141
+ store.commit(table.update(newValue))
142
142
  } else {
143
- store.mutate(table.update({ where: { id }, values: { value: newValue } }))
143
+ store.commit(table.update({ where: { id }, values: { value: newValue } }))
144
144
  }
145
- // store.mutate(updateMutationForQueryInfo(query$.queryInfo!, { value: newValue }))
145
+ // store.commit(updateMutationForQueryInfo(query$.queryInfo!, { value: newValue }))
146
146
  }
147
147
  } else {
148
148
  const setState = // TODO: do we have a better type for the values that can go in SQLite?
@@ -155,8 +155,8 @@ export const useRow: {
155
155
  // @ts-expect-error TODO fix typing
156
156
  if (queryRef.valueRef.current[columnName] === newValue) return
157
157
 
158
- store.mutate(table.update({ where: { id: id ?? 'singleton' }, values: { [columnName]: newValue } }))
159
- // store.mutate(updateMutationForQueryInfo(query$.queryInfo!, { [columnName]: newValue }))
158
+ store.commit(table.update({ where: { id: id ?? 'singleton' }, values: { [columnName]: newValue } }))
159
+ // store.commit(updateMutationForQueryInfo(query$.queryInfo!, { [columnName]: newValue }))
160
160
  })
161
161
 
162
162
  setState.setMany = (columnValuesOrFn: Partial<TComponentState>) => {
@@ -173,8 +173,8 @@ export const useRow: {
173
173
  return
174
174
  }
175
175
 
176
- store.mutate(table.update({ where: { id: id ?? 'singleton' }, values: columnValues }))
177
- // store.mutate(updateMutationForQueryInfo(query$.queryInfo!, columnValues))
176
+ store.commit(table.update({ where: { id: id ?? 'singleton' }, values: columnValues }))
177
+ // store.commit(updateMutationForQueryInfo(query$.queryInfo!, columnValues))
178
178
  }
179
179
 
180
180
  return setState as any
package/tmp/pack.tgz CHANGED
Binary file