halfnelson / svelte-native

Svelte controlling native components via Nativescript
MIT License
1.82k stars 78 forks source link

Two-way Data Binding is not Consistent with Svelte implementation #294

Open TheBeachMaster opened 2 years ago

TheBeachMaster commented 2 years ago

Environment

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?

CatchABus commented 1 year ago

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.

farfromrefug commented 1 year ago

@CatchABus I see. Never use thé preprocessor. Bût I LL try to fix it. Not durr I can publish that package though