Giter VIP home page Giter VIP logo

Comments (4)

FoggyFinder avatar FoggyFinder commented on August 21, 2024

It seems like a bug to me, more simple mcve below:

let test() = 
    let value = Mutable.create ""

    use dynamicVm = Binding.createSource ()
    let validator = (notNullOrWhitespace >> hasLengthAtLeast 3)
    Binding.mutateToFromViewValidated dynamicVm "Value" validator value
    
    dynamicVm.IsValid |> printfn "empty string: %A" //true, should be false 
    value.Value <- "Valid"

    dynamicVm.IsValid |> printfn "Valid string : %A"  //true, should be true

    value.Value <- "-"
    dynamicVm.IsValid |> printfn "Invalid string : %A"  //true, should be false 

from gjallarhorn.

FoggyFinder avatar FoggyFinder commented on August 21, 2024

Okay, I guess I found why it happened. There a two reasons:

  1. The part of code that responds for updating the mutable.
    https://github.com/ReedCopsey/Gjallarhorn/blob/master/src/Gjallarhorn/IO.fs#L95-L99

it seems like updating only when changing validation result instead of just a value, so I think it should be something like that:

    let subscription = 
        validated
        |> Signal.Subscription.create(Option.iter(Mutable.set input))
  1. About "decorator".
    https://github.com/ReedCopsey/Gjallarhorn/blob/master/src/Gjallarhorn/IO.fs#L88-L89

MutatableInOut inherit InOut instead of ValidatedInOut, so there:

https://github.com/ReedCopsey/Gjallarhorn/blob/master/src/Gjallarhorn.Bindable/BindingSource.fs#L125-L128

can't be convert to ValidatedInOut

from gjallarhorn.

ReedCopsey avatar ReedCopsey commented on August 21, 2024

Thank you @FoggyFinder - You were right about the underlying problem - changing the inheritance solved this. Added 2 new tests for this as well.

from gjallarhorn.

kirill-gerasimenko avatar kirill-gerasimenko commented on August 21, 2024

Thank you for reacting to this so quickly and fixing the issue!

from gjallarhorn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.