-
Notifications
You must be signed in to change notification settings - Fork 53
feat: support for solid-js #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
There's a problem with the implementation of the Because the We'll need a way to pass a function/getter to |
Please take a look at my vue 2/3 implementation UPD |
Do you think we can open a PR to TanStack Store Vue/Solid/Svelte instead for them to accept a getter/ref instead? Or just improve it all in all? |
Fix link |
You can of course open a PR with something like this change. Since this package is small I don't see any restrictions for using the core version. without framework wrappers export const useStore = (
getStore: () => Store<any, any> | Derived<any, any>,
selector: (v: any) => any
) => {
let unsub = () => {}
const state = createMemo(() => {
const store = getStore()
const [slice, setSlice] = createStore({
value: selector(store.state),
})
unsub = store.subscribe(() => {
const newValue = selector(store.state)
setSlice(`value`, reconcile(newValue))
})
return slice
})
onCleanup(() => {
unsub()
})
return () => state().value
} UPD |
FYI — we've removed the tanstack/store to do a direct integration w/ the frameworks (more control means more speed). The vue code is a good example of how to directly integrate with framework reactive primitives. Would love to get a solid package out! https://github.com/TanStack/db/blob/main/packages/vue-db/src/useLiveQuery.ts |
Sounds awesome! I'll take a look over the weekend to see what I can do. |
09d9274
to
fe5b86f
Compare
OK, I've updated the integration. I need feedback on the API for Right now, I've set it up so that it always receives a function because if users pass a regular object they might accidentally break reactivity, but we can support both live query config object and as a function similar to Tanstack Query. I just prefer having one way of doing things which will always work. I also ended up installing vitest and jsdom to run tests. Before, we were using |
Another question, do we want to support suspense? |
fe5b86f
to
f62805a
Compare
One way of doing thing sounds good. I don't use Solid so I don't know what people expect per se from libraries like this but supporting Suspense seems like a good plan. What's involved with adding that? If it's pretty involved, it could come in another PR. |
3b89b0c
to
944eb47
Compare
Well, suspense means we use I think we can add it, I just need to figure out which part is doing the async part to inject We can merge this, and I'll can do a follow-up MR for suspense if we want it. |
edfa1cd
to
d90cbf3
Compare
You can call .preload on the query as that promise resolves when all the data from any collections used has loaded. |
The query itself is sync |
…for initial sync.
OK, I think we have suspense as well. I'll try to rebuild the todo app example to verify that everything works. |
Awesome! |
No description provided.