Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Implementing TC39 signal polyfill with tansu #145

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

divdavem
Copy link
Member

@divdavem divdavem commented Jan 15, 2025

Note that this implementation differs a bit from the current TC39 specifications to take into account the issues I opened:

  • Signal.subtle.watched/unwatched callbacks are not only called when a signal is watched/unwatched but also when a signal is read (cf this issue)
  • There is a stabilization process happening when calling set in computed (cf this issue)
  • Signals are not recomputed when dependent signals come back to the previous values used for last computation (cf this issue)

In this PR I have imported the tests from the official polyfill but I have disabled/updated some of them because of the above changes. I have also added some other tests.

I don't like the changes I have added in the last commit. I think calling watch on a watcher should also update the watched signals, as suggested here and implemented in #146.

Copy link

codecov bot commented Jan 15, 2025

Codecov Report

Attention: Patch coverage is 90.43825% with 24 lines in your changes missing coverage. Please review.

Project coverage is 97.72%. Comparing base (b5aebe9) to head (5a4825b).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
src/wrapper.ts 92.30% 8 Missing and 4 partials ⚠️
src/internal/storeDerived.ts 30.76% 9 Missing ⚠️
src/internal/storeConst.ts 33.33% 2 Missing ⚠️
src/internal/storeTrackingUsage.ts 94.73% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##            master     #145      +/-   ##
===========================================
- Coverage   100.00%   97.72%   -2.28%     
===========================================
  Files           16       18       +2     
  Lines          856     1098     +242     
  Branches       133      183      +50     
===========================================
+ Hits           856     1073     +217     
- Misses           0       21      +21     
- Partials         0        4       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@divdavem divdavem changed the title [WIP] Implementing signal polyfill with tansu [WIP] Implementing TC39 signal polyfill with tansu Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant