svelte-native
svelte-native copied to clipboard
Two-way Data Binding is not Consistent with Svelte implementation
Environment
- Nativescript v8.2.3
- Node v17.9.0
Background
Reading this piece in Svelte Docs, what's important here is this piece
If you're using bind: directives together with on: directives, the order that they're defined in affects the value of the bound variable when the event handler is called.
Expected Behavior
The expected behavior for 2 way data binding can be seen on this repl
What's happening
This works in reverse with Svelte-Native
Example
Say you have a couple of sliders like so
<slider
minValue="0"
maxValue="255"
on:valueChange={onValueChangedGreen}
bind:value={green}
/>
<slider
minValue="0"
maxValue="255"
bind:value={black}
on:valueChange={onValueChangedBlack}
/>
The "green" slider will behave as expected and not the "black" slider - expected here means that immediately you slide the slider, the value increments from 0 and not "undefined"
Notice the difference between the order of the directives.
Issue
Is this a bug or expected behavior?
This seems to be a problem possibly caused by https://github.com/halfnelson/svelte-native-preprocessor/blob/master/src/index.ts @farfromrefug I think that package needs improvements.
@CatchABus I see. Never use thé preprocessor. Bût I LL try to fix it. Not durr I can publish that package though