Comments (2)
I've been playing around with this myself, as RxDB looks great and having better type support via hooks would be great.
https://github.com/emab/rxdb-hooks-todo/blob/dcd4f8a6c60ee9898db075f1cff2cc5396fa0a1f/src/Todo.tsx
Here's an example Todo application, with some hooks. The typing right now is baked into the hooks - so thinking of a way of handling this would be great.
In Redux you often export your own versions of a useSelector
hook, providing your store type with them:
import { useDispatch, useSelector, useStore } from 'react-redux'
import type { AppDispatch, AppStore, RootState } from './store'
// Use throughout your app instead of plain `useDispatch` and `useSelector`
export const useAppDispatch = useDispatch.withTypes<AppDispatch>()
export const useAppSelector = useSelector.withTypes<RootState>()
export const useAppStore = useStore.withTypes<AppStore>()
I'm thinking if I take what I have now and apply this methodology we should end up with nicely typed hooks.
The next step would be getting them more feature complete - so maybe doing this approach in this repo would be better.
from rxdb-hooks.
Hey @emab, I am glad someone is still looking into this.
I got this working really well in my repo, but I never got around to actually making a PR and I am not working on the project where I did this already, so I guess I never will... Maybe someone else could take it over the finish line, or at least be inspired by my approach, so here is the repo. Check out the /rxdb-hooks/hooks.tsx
file for the definition of the typed hook builder and the rxdb/db.tsx
for the usage.
The project is also using supabase replication, so if that is your case, there is a custom script that introspects your supabase and generates the schemas for you.
from rxdb-hooks.
Related Issues (20)
- useRxCollection returns null the first time it is called? HOT 2
- useRxCollection does not support lazy collection initialization HOT 7
- Wrong paths in package.json HOT 2
- Database type doesn't match type expected by Provider HOT 2
- useRxData doesn't support findOne HOT 2
- useRxData doesn't support findByIds HOT 2
- Electron remote breaks hooks
- Is RXDB v12 supported? HOT 2
- Support RxDB 12
- How to handle multiple databases? HOT 2
- Question: useRXCollection not able to notice deletion and recreation of collection in one sitting HOT 1
- New functionality: collection.count HOT 1
- rxdb 13 breaks lazy collection creation HOT 1
- hooks stuck loading on local but work on production HOT 10
- useRxData doesn't return result and keeps fetching HOT 2
- How to combine multiple collection queries into a single hook?
- TypeScript + useRxCollection() + static methods not working?
- useRxData collection filtering briefly malfunctions
- collection.remove$ Does not seem to be observable HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rxdb-hooks.