Skip to content
This repository was archived by the owner on Mar 23, 2024. It is now read-only.

Commit a763b5e

Browse files
committed
mg
2 parents c204ade + 23b0b41 commit a763b5e

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

README.MD

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,13 @@ But how is this code working / running on the server? request$ is not an actual
101101
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:
102102

103103
```ts
104-
query(myFn)
104+
query$(myFn)
105105
```
106106

107107
becomes
108108

109109
```ts
110-
query(server$(myFn))
110+
query$(server$(myFn))
111111
```
112112

113113
This piece of code make the function run on the server, but how do we access the request?
@@ -129,3 +129,24 @@ query$(({ request$ }) => {
129129
const headers = server$.request.headers
130130
})
131131
```
132+
133+
How do i run it on the client side?
134+
135+
query$ returns: `(...) => createQuery(...)`
136+
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.
137+
138+
So:
139+
140+
```ts
141+
const myQuery = query$(myFn)
142+
```
143+
144+
Can be used client side (still will run on the server):
145+
146+
```ts
147+
const queryRes = myQuery(()=> input);
148+
149+
// queryRes is basically tanstack query
150+
queryRes.isLoading;
151+
queryRes.data;
152+
```

0 commit comments

Comments
 (0)