Open boorad opened 2 months ago
The (there's never any changes in db.subscribe())
is something that happens to a lot of people. I think I should update the API so that it doesn't pass any data, ever. Then people would know it is just an event they can use to know when to query the database. That's how I use it 90% of the time. Hence, it has an optional second argument when you pass true
that returns the data items. The reason why is in conditions of post merge (remote events), fetching the data items can be somewhat expensive, which makes no sense when they are discarded 90% of the time. Curious for your thoughts on the API.
It would be interesting to see what issues show up when trying useLiveQuery
as that should be the main API in react. It's probably worth bridging the gap unless there is something weird there.
db.subscribe()
Aha, so all your docs have to do is compensate for me being an idiot and not reading / understanding. I do think you should add a bit about that boolean flag in the docs, like:
Note: Use
returnChangeData: boolean
argument to return the changed data
The latest commit has this working and refreshing the Todo List after any change, but it is kind of slow. Like a second or two of logging, and then the mobile UI updates. That could be me not exactly getting the call semantics correct.
useLiveQuery()
Can you talk to how the index is stored (prolly trees)? From the docs:
By default, Fireproof stores data in the browser's local storage
RN doesn't have local storage, so wondering how I can override and store in MMKV or similar.
I see the proper number of documents coming from useLiveQuery
but they're all undefined, and have that `{_key: ..., _value: ...} format.
This PR adds the required bits to have a fully-functional Fireproof database in a React Native mobile application. The biggest difference is polyfilling certain global objects that are expected to be present in Node or a browser with alternatives that work in React Native.
We also add an example RN app showcasing Fireproof as the live database.
react-native-quick-crypto
librarystore-native
logic and use MMKV as local storageuseLiveQuery
to work, instead ofdb.allDocs()
?FlatList
component to not throw React Hooks error?Note: Until
react-native-quick-crypto
gets support forsubtle.encrypt()
andsubtle.decrypt()
, you need to use{public: true}
database option: