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

feat: add impl_into argument to #[server] proc_macro #2334

Closed
wants to merge 26 commits into from

Conversation

videobitva
Copy link
Contributor

This PR adds an optional impl_into named argument for server_fn proc macro.
This argument defaults to true and enables (or disables) the impl of From trait for server function argument type.

In cases when the server function has more than one argument, the impl_into has no effect on the trait impl generation, as it has been already disabled by function arguments number check.

The related issue has been discussed here: https://discord.com/channels/1031524867910148188/1203001939089035295

TL;DR: orphan rules disable (in some cases) the implementation of From trait for conversion between the only server function argument and server function argument type.

The minimal example of the issue lives here: https://github.com/videobitva/test_server_fn

videobitva and others added 22 commits February 3, 2024 00:30
This warning appears in the browser's console log.

```
hackernews.js:933 At src/routes/stories.rs:39:17, you are reading a resource in `hydrate` mode outside a <Suspense/> or <Transition/>. This can cause hydration mismatch errors and loses out on a significant performance optimization. To fix this issue, you can either:
1. Wrap the place where you read the resource in a <Suspense/> or <Transition/> component, or
2. Switch to using create_local_resource(), which will wait to load the resource until the app is hydrated on the client side. (This will have worse performance in most cases.)
```
…ntegration (leptos-rs#2241)

* fix: error rather than panicking if unable to send response in Axum integration
Note that this is a minimal implementation and will __not__ allow the
user to `expect_state` if they have external calls to rendering their
app (i.e. using `render_app_to_*` directly).
This warning is seen in the browsers console window.

```
counter_isomorphic.js:1068 At src/counters.rs:138:17, you are reading a resource in `hydrate` mode outside a <Suspense/> or <Transition/>. This can cause hydration mismatch errors and loses out on a significant performance optimization. To fix this issue, you can either:
1. Wrap the place where you read the resource in a <Suspense/> or <Transition/> component, or
2. Switch to using create_local_resource(), which will wait to load the resource until the app is hydrated on the client side. (This will have worse performance in most cases.)
```

Two derived signals "value" and "error_msg" need to be wrapped in a <Suspense> block.

"value" falls back to just the initial text.
"error" uses the default fallback.
@benwis
Copy link
Contributor

benwis commented Feb 17, 2024

You might need to recreate your PR against the most recent version, you're pulling in a lot of old/extra PRs

@videobitva
Copy link
Contributor Author

You might need to recreate your PR against the most recent version, you're pulling in a lot of old/extra PRs

Ok, will do that then, thank you!

@videobitva videobitva closed this Feb 17, 2024
@videobitva
Copy link
Contributor Author

PR without old/extra PRs is now here: #2335

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 this pull request may close these issues.