@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.
- package/dist/.tsbuildinfo +1 -1
- package/dist/LiveStoreProvider.d.ts +8 -2
- package/dist/LiveStoreProvider.d.ts.map +1 -1
- package/dist/LiveStoreProvider.js +11 -5
- package/dist/LiveStoreProvider.js.map +1 -1
- package/dist/LiveStoreProvider.test.js +2 -2
- package/dist/useAtom.js +5 -5
- package/dist/useQuery.test.js +5 -5
- package/dist/useRow.js +7 -7
- package/dist/useRow.test.js +7 -7
- package/package.json +5 -5
- package/src/LiveStoreProvider.test.tsx +2 -2
- package/src/LiveStoreProvider.tsx +17 -6
- package/src/__snapshots__/useRow.test.tsx.snap +8 -8
- package/src/useAtom.ts +5 -5
- package/src/useQuery.test.tsx +5 -5
- package/src/useRow.test.tsx +7 -7
- package/src/useRow.ts +7 -7
- package/tmp/pack.tgz +0 -0
package/src/useRow.test.tsx
CHANGED
|
@@ -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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
141
|
+
store.commit(table.update(newValue))
|
|
142
142
|
} else {
|
|
143
|
-
store.
|
|
143
|
+
store.commit(table.update({ where: { id }, values: { value: newValue } }))
|
|
144
144
|
}
|
|
145
|
-
// store.
|
|
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.
|
|
159
|
-
// store.
|
|
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.
|
|
177
|
-
// store.
|
|
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
|