-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
docs(start): createIsomorphicFn and envOnly #4806
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
base: main
Are you sure you want to change the base?
Conversation
c503c69
to
a675dae
Compare
### Complete Implementation | ||
|
||
```tsx | ||
const getEnv = createIsomorphicFn() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make those snippets complete by adding the import from '@tanstack/solid-start'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
applies to all examples
@@ -0,0 +1,3 @@ | |||
--- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
once we have settled on the text for react, please duplicate and change the imports to point to solid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hokkyss see the docs in docs/router/framework/solid/devtools.md
which have a syntax for performing text replacements on the ref
doc. So you shouldn't need to duplicate the entire document.
@@ -98,7 +98,7 @@ response?: 'data' | 'full' | 'raw' | |||
- From other server functions | |||
|
|||
> [!WARNING] | |||
> Server functions cannot be called from API Routes. If you need to share business logic between server functions and API Routes, extract the shared logic into utility functions that can be imported by both. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we can now call server functions from API routes. please check and and if true, this text can be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@schiller-manuel is right. API routes as a whole became the new "Server Routes" which support calling Server Function.
This warning can be removed.
we also got those docs recently: b402bbc maybe just improve those where needed? |
@@ -98,7 +98,7 @@ response?: 'data' | 'full' | 'raw' | |||
- From other server functions | |||
|
|||
> [!WARNING] | |||
> Server functions cannot be called from API Routes. If you need to share business logic between server functions and API Routes, extract the shared logic into utility functions that can be imported by both. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@schiller-manuel is right. API routes as a whole became the new "Server Routes" which support calling Server Function.
This warning can be removed.
@@ -0,0 +1,3 @@ | |||
--- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hokkyss see the docs in docs/router/framework/solid/devtools.md
which have a syntax for performing text replacements on the ref
doc. So you shouldn't need to duplicate the entire document.
Use `createIsomorphicFn()` to define functions that behave differently depending on whether they are called on the client or the server. This is useful for safely sharing logic across environments while delegating environment-specific behavior to appropriate handlers. | ||
|
||
> [!WARNING] | ||
> Unimplemented function results in a no-op function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe instead of a warning, this could be a small heading like "What is a no-op?", that'd show the user the type of a no-op.
Perhaps something like this:
type NoOpFunction = () => undefined // add a comment here
@@ -122,6 +126,10 @@ | |||
"label": "Static Server Functions", | |||
"to": "framework/solid/static-server-functions" | |||
}, | |||
{ | |||
"label": "Environment Functions", | |||
"to": "framework/react/environment-functions" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"to": "framework/react/environment-functions" | |
"to": "framework/solid/environment-functions" |
Add docs for
createIsomorphicFn
,serverOnly
, andclientOnly
.I am not quite sure whether "environment functions" is a good name though