smushball
smushball
SSolidJS
Created by smushball on 5/22/2024 in #support
Await a resource inside a function?
This there a function which achieves something similar as my fictional "waitForResource" function here? Or should I refactor my code?
const myResource = createResource(...)

const handleSubmit = async () => {
const data = myResource(); // T | undefined

const data = await waitForResource(myResource()); // T
}

return (
<form onSubmit={handleSubmit}>...
const myResource = createResource(...)

const handleSubmit = async () => {
const data = myResource(); // T | undefined

const data = await waitForResource(myResource()); // T
}

return (
<form onSubmit={handleSubmit}>...
38 replies