Binding input value to store, skips set method on store

100 views Asked by At

Binding input value to store, changes the value inside store, without using set method first. It actually uses the set method, but when I log incoming data, the store is already changed.

Is this my mistake, or is this problem inside svelte

stackblitz example

EDIT: I have new findings... If i change store so it is just value, without using object with key "value", it seems to work properly Or do i still have bug in my implementation?

new stackblitz example

1

There are 1 answers

0
Hovadko On

Problem is in binding of the input. We are binding to $Handler.value and if input value changes, we are mutating original object as well as firing set method. But if we try to get old store in set method, we are recieving new value because we mutated it.

Only solution i found is to not bind value directly, instead use on:input and call set/update method there