Giter Club home page Giter Club logo

Comments (9)

cannoneyed avatar cannoneyed commented on May 30, 2024 1

Amazing! Thanks so much, might be the fastest fix I've ever seen!

from lit-mobx.

benjamind avatar benjamind commented on May 30, 2024

Interesting, please let me know how your investigations pan out and I'll try and take a deeper look at this asap.

from lit-mobx.

benjamind avatar benjamind commented on May 30, 2024

Have produced a quick repro:

https://stackblitz.com/edit/typescript-zpfftr

from lit-mobx.

benjamind avatar benjamind commented on May 30, 2024

Ok what appears to be happening is that the observable tracking from the Reaction setup is not completed until after firstUpdated is called, this is due to firstUpdated being called synchronously after the render completes.

The Reaction we setup is observing the access through the performUpdate function which in turn triggers render, but the reaction captures the state after this function completes. So making a change in firstUpdated is not detected because its already set to the new value as far as the Reaction is concerned..

Not exactly sure the best approach here to fix. @justinfagnani any suggestions? I feel like we 'could' requestUpdate after track to force a second render pass to capture any changes after firstUpdate but this seems less than ideal in the majority of cases where state is not modified in firstUpdate. However we're clearly violating the description of firstUpdated right now so we do need to fix this one somehow I think?

from lit-mobx.

benjamind avatar benjamind commented on May 30, 2024

One approach that appears to work is to create the Reaction over the update method rather than performUpdate, this way the reaction is setup over the state before firstUpdated is called and we get a requestUpdate reaction after firstUpdated completes. @justinfagnani do you see any issues with this?

from lit-mobx.

justinfagnani avatar justinfagnani commented on May 30, 2024

I suspect this will also be a problem for state changes in updated(), and in update() after the super.update() call.

from lit-mobx.

benjamind avatar benjamind commented on May 30, 2024

I guess we could setup separate reactions around each of these functions in a similar manner? Its a little more code, but not a lot, and I guess would solve in each case.

from lit-mobx.

justinfagnani avatar justinfagnani commented on May 30, 2024

Tracking super.update() might be ok. Then any subclasses that make state changes after their own super.update() call should work.

from lit-mobx.

benjamind avatar benjamind commented on May 30, 2024

@cannoneyed this fix has been published under 0.0.4.

from lit-mobx.

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.