Skip to content

feat: dispose effect() with resource management - #706

Merged
marvinhagemeister merged 2 commits into
mainfrom
resource-management
Jun 28, 2025
Merged

feat: dispose effect() with resource management#706
marvinhagemeister merged 2 commits into
mainfrom
resource-management

Conversation

@marvinhagemeister

Copy link
Copy Markdown
Member

Add support for disposing effect()'s with the using keyword from the stage 3 explicit resource management proposal.

const count = signal(0);

function doSomething() {
  // The `using` keyword calls dispose at the end of
  // this function scope
  using _ = effect(() => {
    console.log(count.value);
    return () => console.log("disposed");
  });

  console.log("hey");
}

doSomething();
// Logs:
//  0
//  hey
//  disposed

Needed to update the babel toolchain to support parsing the using keyword in our test setup.

@changeset-bot

changeset-bot Bot commented Jun 28, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4045d2d

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

This PR includes changesets to release 1 package
Name Type
@preact/signals-core Minor

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

@netlify

netlify Bot commented Jun 28, 2025

Copy link
Copy Markdown

Deploy Preview for preact-signals-demo ready!

Name Link
🔨 Latest commit f91e99b
🔍 Latest deploy log https://app.netlify.com/projects/preact-signals-demo/deploys/685fd4c4a5f86500089ae668
😎 Deploy Preview https://deploy-preview-706--preact-signals-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions

github-actions Bot commented Jun 28, 2025

Copy link
Copy Markdown
Contributor

Size Change: -51 B (-0.06%)

Total Size: 87.6 kB

Filename Size Change
docs/dist/assets/bench.********.js 1.59 kB +1 B (+0.06%)
docs/dist/assets/signals-core.module.********.js 1.53 kB +14 B (+0.93%)
docs/dist/assets/signals.module.********.js 2.04 kB -1 B (-0.05%)
docs/dist/demos-********.js 4.32 kB -4 B (-0.09%)
docs/dist/nesting-********.js 1.13 kB +2 B (+0.18%)
docs/dist/react-********.js 239 B -2 B (-0.83%)
packages/core/dist/signals-core.js 1.56 kB +15 B (+0.97%)
packages/core/dist/signals-core.mjs 1.57 kB +13 B (+0.83%)
packages/react-transform/dist/signals-*********.js 5.93 kB -40 B (-0.67%)
packages/react-transform/dist/signals-transform.mjs 5.12 kB -10 B (-0.2%)
packages/react-transform/dist/signals-transform.umd.js 6.04 kB -39 B (-0.64%)
ℹ️ View Unchanged
Filename Size
docs/dist/assets/client.********.js 46.2 kB
docs/dist/assets/index.********.js 1.09 kB
docs/dist/assets/jsxRuntime.module.********.js 283 B
docs/dist/assets/preact.module.********.js 4.01 kB
docs/dist/assets/style.********.js 21 B
docs/dist/assets/style.********.css 1.24 kB
docs/dist/basic-********.js 243 B
packages/preact/dist/signals.js 1.57 kB
packages/preact/dist/signals.mjs 1.53 kB
packages/react/dist/signals.js 188 B
packages/react/dist/signals.mjs 150 B

compressed-size-action

Comment thread tsconfig.json
"stripInternal": true,
"noUnusedLocals": true,
"noEmit": true,
"skipLibCheck": true,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed to add this because the newer TS version complains about something in sinon types

@JoviDeCroock JoviDeCroock left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a great addition!

@marvinhagemeister
marvinhagemeister merged commit eb4fa82 into main Jun 28, 2025
6 checks passed
@marvinhagemeister
marvinhagemeister deleted the resource-management branch June 28, 2025 11:46
@github-actions github-actions Bot mentioned this pull request Jun 28, 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.

2 participants