Skip to content

Commit 3244f04

Browse files
committed
docs(guide): add guide to the docs
1 parent 16f32e7 commit 3244f04

File tree

19 files changed

+157
-36
lines changed

19 files changed

+157
-36
lines changed

packages/examples/todolist-ts/.eslintrc.cjs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ module.exports = {
55
project: ['./tsconfig.json', './tsconfig.app.json', './tsconfig.node.json'],
66
parser: '@typescript-eslint/parser',
77
},
8-
rules: {
9-
'import/no-unresolved': [2, { ignore: ['vue-tinybase/typed'] }],
10-
},
118
settings: {
129
'import/resolver': {
1310
node: {

packages/examples/todolist-ts/src/components/todos/NewTodoInput.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<script setup lang="ts">
22
import { ref } from 'vue'
3-
import { useStore } from 'vue-tinybase'
3+
import { injectStore } from 'vue-tinybase'
44
5-
const store = useStore()
5+
const store = injectStore()
66
77
const newTodoText = ref('')
88

packages/examples/todolist-ts/src/components/todos/SingleTodo.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
22
import { nextTick, ref } from 'vue'
3-
import { cellRef, useStore } from 'vue-tinybase'
3+
import { cellRef, injectStore } from 'vue-tinybase'
44
55
const props = defineProps<{
66
rowId: string
@@ -26,7 +26,7 @@ function exitEditingMode(save = false) {
2626
}
2727
}
2828
29-
const store = useStore()
29+
const store = injectStore()
3030
function removeTodo() {
3131
store.delRow('todos', props.rowId)
3232
}

packages/examples/todolist-ts/src/components/todos/TodosFooter.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<script setup lang="ts">
22
import { computed } from 'vue'
33
import { RouterLink } from 'vue-router'
4-
import { useStore, useTable } from 'vue-tinybase'
4+
import { injectStore, useTable } from 'vue-tinybase'
55
6-
const { data: table } = useTable('todos')
6+
const table = useTable('todos')
77
const entries = computed(() => Object.entries(table.value))
88
const activeEntries = computed(() => entries.value.filter(([_, entry]) => !entry.completed))
99
const completedEntries = computed(() => entries.value.filter(([_, entry]) => entry.completed))
1010
11-
const store = useStore()
11+
const store = injectStore()
1212
function clearCompleted() {
1313
for (const entry of completedEntries.value) {
1414
store.delRow('todos', entry[0])
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
import 'todomvc-app-css/index.css'
2-
import { createApp } from 'vue'
3-
import { createTinybaseVue } from 'vue-tinybase'
2+
import { createApp, h } from 'vue'
3+
import { provideStore } from 'vue-tinybase'
44

55
import App from '@/App.vue'
66
import { router } from '@/router'
77
import { store } from '@/store'
88

9-
const app = createApp(App)
9+
const app = createApp({
10+
setup() {
11+
provideStore(store)
12+
},
13+
render: () => h(App),
14+
})
1015

1116
app.use(router)
12-
app.use(createTinybaseVue(store))
1317

1418
app.mount('#app')

packages/examples/todolist-ts/src/store.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ export const store = createStore()
1313
val2: { type: 'number', default: 0 },
1414
val3: { type: 'boolean', default: false },
1515
})
16-
export const store2 = createStore().setValuesSchema({
17-
val10: { type: 'string' },
18-
})
1916

2017
const persister = createLocalPersister(store, 'todos')
2118

22-
await persister.startAutoLoad()
23-
await persister.startAutoSave()
19+
// eslint-disable-next-line unicorn/prefer-top-level-await
20+
void (async () => {
21+
await persister.startAutoLoad()
22+
await persister.startAutoSave()
23+
})()
2424

2525
export type Store = typeof store
2626

packages/examples/todolist-ts/src/views/filtered/ActiveTodos.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
22
import { computed } from 'vue'
3-
import { useTable } from 'vue-tinybase/typed'
3+
import { useTable } from 'vue-tinybase'
44
55
import TodosList from '@/components/todos/TodosList.vue'
66

packages/examples/todolist-ts/src/views/filtered/AllTodos.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<script setup lang="ts">
22
import { computed } from 'vue'
3-
import { useStore, useTable } from 'vue-tinybase'
3+
import { injectStore, useTable } from 'vue-tinybase'
44
55
import TodosList from '@/components/todos/TodosList.vue'
66
7-
const { data: table } = useTable('todos')
7+
const table = useTable('todos')
88
const rowIds = computed(() => Object.keys(table.value))
99
10-
const store = useStore()
10+
const store = injectStore()
1111
const allCompleted = computed({
1212
get: () => rowIds.value.length > 0 && rowIds.value.every(rowId => table.value[rowId].completed),
1313
set: (value: boolean) => {

packages/examples/todolist-ts/src/views/filtered/CompletedTodos.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useTable } from 'vue-tinybase'
44
55
import TodosList from '@/components/todos/TodosList.vue'
66
7-
const { data: table } = useTable('todos')
7+
const table = useTable('todos')
88
const entries = computed(() => Object.entries(table.value))
99
const completedEntries = computed(() => entries.value.filter(([_, entry]) => entry.completed))
1010
const rowIds = computed(() => completedEntries.value.map(([rowId, _]) => rowId))

packages/examples/todolist-ts/vite.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ export default defineConfig({
1010
resolve: {
1111
alias: {
1212
'@': fileURLToPath(new URL('src', import.meta.url)),
13-
'vue-tinybase/typed': 'vue-tinybase',
1413
'tinybase/with-schemas/persisters/persister-browser': 'tinybase/persisters/persister-browser',
1514
},
1615
},

0 commit comments

Comments
 (0)