Giter VIP home page Giter VIP logo

Comments (5)

BenjiFarquhar avatar BenjiFarquhar commented on July 18, 2024 1

Cool, I'm happy with the verdict. reactive_forms_lbc looks useful, cheers.

from reactive_forms_generator.

BenjiFarquhar avatar BenjiFarquhar commented on July 18, 2024

Do note that the required validator trims the white space so the value ' ' is indeed invalid, and I did 2 spaces so that it is different to the model and enters the important code in didUpdateWidget.

from reactive_forms_generator.

vasilich6107 avatar vasilich6107 commented on July 18, 2024

It reconstructs only if

if (widget.model != oldWidget.model)

So if you are changing the model it means that this is new form so everything will be new

Implement proper object equality with equatable or freezed to have consistent behavior

from reactive_forms_generator.

BenjiFarquhar avatar BenjiFarquhar commented on July 18, 2024

I managed to change my app to make it work. I will ponder this form becoming pristine on model updates behaviour some more before I close.

I'm building a complex object by listening to formModel.form.valueChanges, and my forms also need to read that complex object, so it listens to it and rebuilds.

It worked in version 0.24, but I think in version 1.0.0, when the form rebuilds, didUpdateWidget is running with a different model (by one character), causing the reconstruction with pristine.

For my solution I don't update the complex object in formModel.form.valueChanges anymore, so the form no longer rebuilds on value change. I do it on button presses, when it is okay to allow the form to be pristine, and also put the current form state that is missing from the complex object, in a separate object so I can get a full picture of the complex object now from 2 different objects.

from reactive_forms_generator.

vasilich6107 avatar vasilich6107 commented on July 18, 2024

There is https://pub.dev/packages/reactive_forms_lbc package which could help you to simplify listening

In overall it makes more sense to pass model into form and then operate the using form methods without resupplying the form with new model

from reactive_forms_generator.

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.