hybridsjs / hybrids

Extraordinary JavaScript UI framework with unique declarative and functional architecture
https://hybrids.js.org
MIT License
3.06k stars 87 forks source link

fix(cache): Clear deps and context when get value from cache #230

Closed smalluban closed 10 months ago

smalluban commented 10 months ago

Relates to #229

Still updating properties in a chain of the observer can lead to out-of-date UI, as the render method is added to the emitter queue when the first of its dependencies has changed. Added test to this PR shows that case - render is called after the prop1 observer, so the prop1 and prop2 are updated, but before the prop3 (it is added to the queue when render is there already).

However, the PR fixes the issue where the state after that action is broken, and render has no deps anymore (before calling host.prop3 = ... cleared out deps/contexts of a whole tree, so render has no deps then, but it also will not be called, as it was called already).

codesandbox-ci[bot] commented 10 months ago

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 333ca5ae3f3310786997deeb9512f6904df2148d:

Sandbox Source
Hybrids web components playground Configuration
coveralls commented 10 months ago

Coverage Status

coverage: 100.0%. remained the same when pulling 333ca5ae3f3310786997deeb9512f6904df2148d on fix-cache-clear-deps-context into ffba323d340cbb969ccb6c6dca4b4a84c4761bfe on main.