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

Commit

Permalink
mg
Browse files Browse the repository at this point in the history
  • Loading branch information
OrJDev committed Mar 3, 2023
2 parents c204ade + 23b0b41 commit a763b5e
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -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;
```

1 comment on commit a763b5e

@vercel
Copy link

@vercel vercel bot commented on a763b5e Mar 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

prpc-docs – ./

prpc.vercel.app
prpc-docs-git-main-orjdev.vercel.app
prpc-docs-orjdev.vercel.app
prpc-docs.vercel.app

Please sign in to comment.