From 23b0b4109bee257d6022d18e27bbf8f313386af7 Mon Sep 17 00:00:00 2001 From: OrJDev <91349014+OrJDev@users.noreply.github.com> Date: Fri, 3 Mar 2023 09:01:35 +0200 Subject: [PATCH] Update README.MD --- README.MD | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/README.MD b/README.MD index e9551a2..9362265 100644 --- a/README.MD +++ b/README.MD @@ -101,13 +101,13 @@ But how is this code working / running on the server? request$ is not an actual We use a babel plugin built on top of vite that is meant to wrap functions that passed to query$ with server, so for instance: ```ts -query(myFn) +query$(myFn) ``` becomes ```ts -query(server$(myFn)) +query$(server$(myFn)) ``` This piece of code make the function run on the server, but how do we access the request? @@ -129,3 +129,24 @@ query$(({ request$ }) => { const headers = server$.request.headers }) ``` + +How do i run it on the client side? + +query$ returns: `(...) => createQuery(...)` +So what it does is, it is taking the function that is running on the server (wrapped with server$) and basically try to query it using `createQuery` from solid query. + +So: + +```ts +const myQuery = query$(myFn) +``` + +Can be used client side (still will run on the server): + +```ts +const queryRes = myQuery(()=> input); + +// queryRes is basically tanstack query +queryRes.isLoading; +queryRes.data; +```