Created
March 10, 2024 00:21
-
-
Save HerringtonDarkholme/c5c3da02756e27f9226bdcdc6e49a154 to your computer and use it in GitHub Desktop.
we have server component and server action. why not unify together to be a server signal?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const emailRef = ref('') | |
const userBio = server(async () => { | |
const findUser = await import('./server') | |
const userRef = ref(null) | |
watch(async () => { | |
userRef.value = await findUser(emailRef.value) | |
}) | |
return (props) => ( | |
h('div', [userRef.value.bio]), | |
) | |
}) | |
const emailInput = client(async () => { | |
const func = await import('./client') | |
return (props) => ( | |
h('input', { | |
onchange: e => emailRef.value = e.target.value, | |
value: emailRef.value, | |
}), | |
) | |
}) | |
export default function render(props) { | |
return h('div', [ | |
h(emailInput), | |
h(userBio), | |
]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment