Skip to content

Instantly share code, notes, and snippets.

@HerringtonDarkholme
Created March 10, 2024 00:21
Show Gist options
  • Save HerringtonDarkholme/c5c3da02756e27f9226bdcdc6e49a154 to your computer and use it in GitHub Desktop.
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?
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