You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! I'm not sure what exactly you need to do, but there is an assumption that you are using setter not for its intended purpose.
Firstly, setter designed to perform some outgoing side-effect when asyncable store value has changed.
Secondery, you try to set the same value. asyncable store is smart enough to don't do anything if nothing is changed.
Lastly, setter callback is not set the store value and returning something from this function is does not perform any action.
<!-- this subscription to the store will perform `getter` callback to fetch user data from the server -->
{#await$userStore}
<p>Loading user data...</p>
{:thenuser}
<formon:submit|preventDefault={save}>
<inputname="firstName"value={user.firstName}>
<inputname="lastName"value={user.lastName}>
<inputname="email"value={user.email}>
<button>Save</button>
</form>
{/await}
<script>
import { userStore } from'./stores/userStore';functionsave(e) {constformData=newFormData(e.target);constuserData=Object.fromEntries(formData.entries());// this store change will perform `setter` callback and send user data updates to the serveruserStore.set(userData); }
</script>
Hope it would help you! Feel free to ask additional questions!
p/s I know that this package docs are awful. Still can't find enough time to make them better. )))
Hey! Looks like setter does not works for me.
The text was updated successfully, but these errors were encountered: