Skip to content

Commit bcf01f1

Browse files
committed
[docs] Some clarifications
1 parent 2975597 commit bcf01f1

File tree

3 files changed

+39
-20
lines changed

3 files changed

+39
-20
lines changed

site/guides/01_the_basics/7_importing_tinybase.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,9 @@ import {createStore, createSqliteBunPersister} from 'tinybase/omni';
7979
```
8080

8181
However, it should go without saying that you should only use the `omni` module
82-
if you have a good tree-shaking bundler that can remove all the persisters,
83-
synchronizers, and so on, that you do _not_ use.
82+
if you have an aggressive tree-shaking bundler that can remove all the
83+
persisters, synchronizers, and so on, that you do _not_ use. Experiment with
84+
different bundler configurations to see what works best for your usage.
8485

8586
## Targets And Formats
8687

site/guides/03_schemas/2_schema_based_typing.md

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,8 @@ import React from 'react';
118118
import * as UiReact from 'tinybase/ui-react/with-schemas';
119119
import {createStore} from 'tinybase/with-schemas';
120120

121-
const tablesSchema = {
122-
pets: {species: {type: 'string'}},
123-
} as const;
124-
const valuesSchema = {
125-
employees: {type: 'number'},
126-
open: {type: 'boolean', default: false},
127-
} as const;
121+
const tablesSchema = {pets: {species: {type: 'string'}}} as const;
122+
const valuesSchema = {employees: {type: 'number'}} as const;
128123

129124
// Cast the whole module to be schema-based with WithSchemas:
130125
const UiReactWithSchemas = UiReact as UiReact.WithSchemas<
@@ -151,17 +146,16 @@ following to explicitly load code and types from different folders:
151146
// code
152147
import React from 'react';
153148
import * as UiReact from 'tinybase/ui-react';
154-
import type {WithSchemas} from 'tinybase/ui-react/with-schemas';
155149
// types
156-
import {TablesSchema, ValuesSchema, createStore} from 'tinybase/with-schemas';
150+
import type {WithSchemas} from 'tinybase/ui-react/with-schemas';
151+
import type {
152+
TablesSchema,
153+
ValuesSchema,
154+
createStore,
155+
} from 'tinybase/with-schemas';
157156

158-
const tablesSchema = {
159-
pets: {species: {type: 'string'}},
160-
} as const;
161-
const valuesSchema = {
162-
employees: {type: 'number'},
163-
open: {type: 'boolean', default: false},
164-
} as const;
157+
const tablesSchema = {pets: {species: {type: 'string'}}} as const;
158+
const valuesSchema = {employees: {type: 'number'}} as const;
165159

166160
const UiReactWithSchemas = UiReact as unknown as WithSchemas<
167161
[typeof tablesSchema, typeof valuesSchema]
@@ -170,6 +164,29 @@ const UiReactWithSchemas = UiReact as unknown as WithSchemas<
170164
//...
171165
```
172166

167+
## Using the `omni` module
168+
169+
You may also need to use the `unknown as` cast when using the `omni` module,
170+
since it exports both the ui-react module and ui-react-dom module, and you will
171+
need to distinguish them:
172+
173+
```tsx yolo
174+
import * as Omni from 'tinybase/omni';
175+
import type {
176+
UiReactDomWithSchemas,
177+
UiReactWithSchemas,
178+
} from 'tinybase/omni/with-schemas';
179+
180+
const tablesSchema = {pets: {species: {type: 'string'}}} as const;
181+
const valuesSchema = {employees: {type: 'number'}} as const;
182+
type Schemas = [typeof tablesSchema, typeof valuesSchema];
183+
184+
const {useCell, useValue} = Omni as unknown as UiReactWithSchemas<Schemas>;
185+
const {EditableCellView} = Omni as unknown as UiReactDomWithSchemas<Schemas>;
186+
187+
//...
188+
```
189+
173190
## Multiple Stores
174191

175192
In the case that you have multiple Store objects with different schemas, you

site/guides/15_releases.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ import {createStore, createSqliteBunPersister} from 'tinybase/omni';
2525
```
2626

2727
However, it should go without saying that you should only use the `omni` module
28-
if you have a good tree-shaking bundler that can remove all the persisters,
29-
synchronizers, and so on, that you do _not_ use.
28+
if you have an aggressive tree-shaking bundler that can remove all the
29+
persisters, synchronizers, and so on, that you do _not_ use. Experiment with
30+
different bundler configurations to see what works best for your usage.
3031

3132
## with-schema exports
3233

0 commit comments

Comments
 (0)