You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+43-5Lines changed: 43 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -187,7 +187,42 @@ This hook returns the current database client with some helpful functions for sy
187
187
188
188
Check out the [Firebase example](https://homebaseio.github.io/homebase-react/#!/example.todo_firebase) for a demonstration of how you might integrate a backend.
189
189
190
-
## Debugging tips
190
+
## Debugging
191
+
Homebase React uses ClojureScript and its corresponding data format EDN internally. We then compile all of that to Javascript using the Google Closure Compiler (closure not clojure, I know right) to get as small a bundle as possible. Then we provide APIs (react hooks) that accept JSON and do all the conversion to EDN and back again behind the scenes.
192
+
193
+
EDN and Clojure provide far more safety and extensibility than JSON and Javascript. Clojure being immutable by default and EDN being extensible. This lets us build and support features that would be unwieldy in JSON and JS.
194
+
195
+
However, the tradeoffs are:
196
+
197
+
1. A larger bundle size. Some of the Clojure runtime cannot be compiled away even though the closure compiler is really aggressive.
198
+
2. Clojure error messages sometimes leak into JS land. We try to annotate the ones we know about so they make sense to JS devs, but it's far from perfect and if you see something weird please create an issue.
199
+
3. Our code is released already minified. We do this because most people do not develop with the google closure compiler and other build tools are not nearly as effective at optimizing this code. This makes debugging homebase-react while developing a bit harder since the code is not very readable, but we think the tradeoff is worth it to provide a smaller bundle size. And to compensate we try to build enough supporting dev tooling so you never need to read the compiled source.
200
+
4. Confusing console logs. EDN data looks different from JSON and to add to that, homebase-react mostly outputs entities, which are lazy data types and not very helpful when logged out with the default console formatting. See custom chrome formatters below for a vastly improved logging experience.
201
+
202
+
### Custom chrome console log formatters
203
+
If you develop with [Chrome](https://www.google.com/chrome/) or a Chromium browser like Brave or Edge you'll get significantly more meaningful logs for entities `console.log(anEntity)` due to our use of custom chrome :formatters. These custom formatters allow us to perform lazy database queries to fetch all of an entity's attributes, including references to other entities and all reverse references to the current entity. They let you access your entire data graph from the console, with any logged out entity as an entry point.
204
+
205
+
**To enable custom chrome formatters**
206
+
207
+
**1.** Open the preferences panel in chrome devtools by clicking the cog.
208
+
209
+
<imgalt="image of chrome devtools preferences button"src="public/images/enable_chrome_formatters_1.png"width="400">
210
+
211
+
**2.** Toggle `Enabled custom formatters` on.
212
+
213
+
<imgalt="image of chrome devtools custom formatters toggle"src="public/images/enable_chrome_formatters_2.png"width="400">
214
+
215
+
**3.** Keep the chrome console open and refresh the page. Any logged out entities should now have the custom formatting.
216
+
217
+
<imgalt="image of custom entity chrome console logs"src="public/images/enable_chrome_formatters_3.png"width="400">
218
+
219
+
**Live demo:** open the console while on the [todo example](https://homebaseio.github.io/homebase-react/#!/dev.example.todo) page.
220
+
221
+
**Remember**: for custom formatters to work `console.log(anEntity)` must be called *after* you open the chrome console. Anything logged out before you open the console will not have custom formatting applied because chrome processes those logs in the background.
If you set `debug` to `true` in your configuration, you will be able to access the `_recentlyTouchedAttributes` attribute on entities. `_recentlyTouchedAttributes` will show any cached attributes for a given entity. This is helpful for approximating that entity's schema and values.
193
228
@@ -199,12 +234,15 @@ If you set `debug` to `true` in your configuration, you will be able to access t
199
234
200
235
## Roadmap
201
236
202
-
1. Document integration with more backends
203
-
2. Swap [Datascript](https://github.com/tonsky/datascript) out for [Datahike](https://github.com/replikativ/datahike)
2. Reactive query planning (better perf on pages with lots of live reads)
241
+
3. Swap [Datascript](https://github.com/tonsky/datascript) out for [Datahike](https://github.com/replikativ/datahike)
204
242
1. Immutability
205
243
2. History / Change Tracking
206
-
3. Persist to IndexedDB
207
-
4.[Local-first](https://www.inkandswitch.com/local-first.html) conflict resolution for offline caching and sync between multiple devices
244
+
4. Persist to IndexedDB
245
+
5.[Local-first](https://www.inkandswitch.com/local-first.html) conflict resolution for offline caching and sync between multiple devices
208
246
209
247
## Limitations
210
248
Homebase React is currently not a good choice for read-heavy applications (e.g. Twitter, ecommerce). We plan to support these query patterns with our [platform](http://homebase.io) eventually.
Copy file name to clipboardExpand all lines: docs/0100|Overview.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ As data and our need to annotate and organize it grows, so does our need for sup
14
14
15
15
To solve this problem, modern write-heavy applications such as Superhuman, Roam Research, and Facebook Messenger built their own embedded data layers to enable these more sophisticated user experiences.
16
16
17
-
Homebase-react enables developers to access the same embedded datalog database as Roam Research through React hooks. You no longer have to build out a team or learn specialized tools like Clojure in order to build a delightful write-heavy application.
17
+
Homebase React enables developers to access the same embedded datalog database as Roam Research through React hooks. You no longer have to build out a team or learn specialized tools like Clojure in order to build a delightful write-heavy application.
Copy file name to clipboardExpand all lines: docs/0200|Quick_Start.md
+13-1Lines changed: 13 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,13 @@
1
+
> We recommend everyone start by [enabling custom chrome formatters](/docs/homebase-react/main/debugging#custom-chrome-formatters) for a much better debugging experience.
2
+
3
+

4
+
5
+
Ok. Let's get going.
6
+
1
7
Homebase React creates a local relational database for your React app.
2
8
9
+
Adding `HomebaseProvider` automatically creates the database.
10
+
3
11
```js
4
12
import { HomebaseProvider } from'homebase-react'
5
13
@@ -33,4 +41,8 @@ const App = () => {
33
41
</button>
34
42
)
35
43
}
36
-
```
44
+
```
45
+
46
+
For a step by step guide take a look at the [tutorial](/docs/homebase-react/main/tutorial).
47
+
48
+
Check out the [API docs](/docs/homebase-react/main/api) to learn about our other hooks like [`useQuery`](/docs/homebase-react/main/api#usequery) and [`useClient`](/docs/homebase-react/main/api#useclient).
Copy file name to clipboardExpand all lines: docs/0300|Tutorial.md
+7-1Lines changed: 7 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,14 @@
1
1
This tutorial takes you through our [Todo Example](https://homebaseio.github.io/homebase-react/#!/example.todo).
2
2
3
+
## Custom chrome formatters
4
+
5
+
> We recommend everyone start by [enabling custom chrome formatters](/docs/homebase-react/main/debugging#custom-chrome-formatters) for a much better debugging experience.
6
+
7
+

8
+
3
9
## HomebaseProvider
4
10
5
-
Let's get started.
11
+
Welcome back. Let's get started for real.
6
12
7
13
`HomebaseProvider` is a component that wraps your React app and creates a local relational database. This database is then accessible to any child components via React Hooks.
Copy file name to clipboardExpand all lines: docs/0400|API.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,7 @@
1
+
> We recommend everyone start by [enabling custom chrome formatters](/docs/homebase-react/main/debugging#custom-chrome-formatters) for a much better debugging experience.
2
+
3
+

4
+
1
5
## `HomebaseProvider`
2
6
3
7
The HomebaseProvider wraps your React app and makes a relational database accessible to all of your components. Configure it with `lookupHelpers` and `initialData`.
0 commit comments