Comments (9)
Amazing! Thanks so much, might be the fastest fix I've ever seen!
from lit-mobx.
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.
Have produced a quick repro:
https://stackblitz.com/edit/typescript-zpfftr
from lit-mobx.
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.
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.
I suspect this will also be a problem for state changes in updated()
, and in update()
after the super.update()
call.
from lit-mobx.
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.
Tracking super.update()
might be ok. Then any subclasses that make state changes after their own super.update()
call should work.
from lit-mobx.
@cannoneyed this fix has been published under 0.0.4
.
from lit-mobx.
Related Issues (20)
- Array of Objects don't request an update HOT 11
- Demo isn't working, state change not causing a re-render HOT 7
- updated not called if observable not used in render HOT 5
- AsyncDirectives prevent mobx observables retriggering update HOT 3
- ESM Module type is missing in package.json
- Upgrade to Lit 3 HOT 9
- ESM support for SSR etc. HOT 1
- An in-range update of @open-wc/testing is breaking the build 🚨 HOT 7
- An in-range update of @open-wc/testing-karma is breaking the build 🚨 HOT 11
- non-typescript examples
- An in-range update of es-dev-server is breaking the build 🚨 HOT 15
- An in-range update of @open-wc/testing-karma is breaking the build 🚨 HOT 16
- Add release tags to make it easier to see changes between releases HOT 3
- Move to v1.0.0 HOT 4
- Does not work with MobX 6.0.0+ HOT 7
- Lit-Mobx and partial rerendering HOT 2
- Mobx6 example does not work with Node 15 / npm 7.3 HOT 2
- Batch updates and lit-mobx HOT 1
- Lit 2 version HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lit-mobx.