Skip to content

feat: allow reading tag variables after they are written #2745

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

Merged
merged 1 commit into from
Jul 22, 2025

Conversation

DylanPiercey
Copy link
Contributor

@DylanPiercey DylanPiercey commented Jul 21, 2025

Description

Tag variables staying in the past after being written has been shown to be cumbersome, error prone, and confusing.

With that we decided to allow reading the "proposed" value after a tag variable has been written.
It is considered "proposed" because rendering logic, derivations and change handlers do not run eagerly when the assignment happens, however in the scope of the current expression you are able to read the last assigned to value of the tag variable.

<let/count=0>
<button onClick() {
  count++;
  console.log(count); // previously would be `0` on first click, now `1`
}/>

Checklist:

  • I have read the CONTRIBUTING document and have signed (or will sign) the CLA.
  • I have updated/added documentation affected by my changes.
  • I have added tests to cover my changes.

@DylanPiercey DylanPiercey force-pushed the read-after-write-tag-var branch from 5ba66e8 to 88cc794 Compare July 21, 2025 18:25
Copy link

changeset-bot bot commented Jul 21, 2025

🦋 Changeset detected

Latest commit: 06e46dc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@marko/runtime-tags Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

codecov bot commented Jul 21, 2025

Codecov Report

Attention: Patch coverage is 89.06250% with 7 lines in your changes missing coverage. Please review.

Project coverage is 88.03%. Comparing base (064f068) to head (06e46dc).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ckages/runtime-tags/src/translator/util/signals.ts 87.93% 7 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2745   +/-   ##
=======================================
  Coverage   88.03%   88.03%           
=======================================
  Files         362      362           
  Lines       44419    44453   +34     
  Branches     3406     3412    +6     
=======================================
+ Hits        39103    39133   +30     
- Misses       5291     5295    +4     
  Partials       25       25           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@DylanPiercey DylanPiercey force-pushed the read-after-write-tag-var branch from 88cc794 to 06e09b7 Compare July 22, 2025 22:02
@DylanPiercey DylanPiercey force-pushed the read-after-write-tag-var branch from 06e09b7 to 06e46dc Compare July 22, 2025 22:16
@DylanPiercey DylanPiercey merged commit 742fca5 into main Jul 22, 2025
11 checks passed
@DylanPiercey DylanPiercey deleted the read-after-write-tag-var branch July 22, 2025 22:24
@github-actions github-actions bot mentioned this pull request Jul 22, 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