Skip to content
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

Redesign serve() and mutate() apis, and maybe getEntry too #119

Closed
dai-shi opened this issue Aug 7, 2023 · 4 comments · Fixed by #124
Closed

Redesign serve() and mutate() apis, and maybe getEntry too #119

dai-shi opened this issue Aug 7, 2023 · 4 comments · Fixed by #124
Assignees

Comments

@dai-shi
Copy link
Owner

dai-shi commented Aug 7, 2023

There are a few things of my concern:

@dai-shi dai-shi self-assigned this Aug 7, 2023
@dai-shi
Copy link
Owner Author

dai-shi commented Aug 8, 2023

New protocol idea (1st iteration)

Request

GET /RSC/<input string>

For callServer:

POST /RSC/<id string>

Response

Promise<{
  value?: unknown
  elements?: { [id: string]: JSXStream },
}>

Current protocol (v0.14.0)

Request

GET /RSC/<id string>/props=<JSON stringified props>

For callServer:

POST /RSC/_/action_id=<string>

Response

JSXStream or value

@dai-shi
Copy link
Owner Author

dai-shi commented Aug 9, 2023

2nd iteration

// Request
GET /RSC/<input string>
POST /RSC/<action id string>

// Response
Promise<{
  v?: unknown // for value
  t?: { [element id string]: JSXElementStream }
}>

// entries.tsx
function render(input: string): Promise<{ [element id string]: JSXElement }>

(Hmm, this doesn't allow "patching"... 🤔 )

@dai-shi
Copy link
Owner Author

dai-shi commented Aug 12, 2023

3rd iteration

// Request
GET /RSC/<input string>
POST /RSC/<action id string>

// Response
Promise<{
  _value: unknown
  [element id string]: JSXElementStream
}>

// entries.tsx
function render(input: string, options: unknown): Promise<{
  [element id string]: JSXElement // element id shouldn't be `_value` or maybe any `_*`
}>

will drop mutate() on client, and introduce rerender(input: string) on server. not sure how to implement serve() yet.

@dai-shi
Copy link
Owner Author

dai-shi commented Aug 27, 2023

3rd iteration

I'm thinking to implement it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant