preactjs / signals

Manage state with style in every framework
https://preactjs.com/blog/introducing-signals/
MIT License
3.82k stars 95 forks source link

RAF aligned effects #595

Closed JoviDeCroock closed 1 month ago

JoviDeCroock commented 3 months ago

At first I thought this would solve https://github.com/preactjs/signals/issues/315 but that's still not the case I think as we are currently only deferring explicit effects, however in this case it's the distinction between re-rendering a VNode and an eagerly recalculating computed.

I guess in an ideal scenario we don't want to allow for synchronous updates within a Preact application, doing so will force us into scenario's where our DOM-tree is newer than our VNode tree

315 is a perfect example of that going wrong 😅 however this PR will be a performance improvement nonetheless as we are not blocking anymore.

I would consider finding a solution to #315 important for mixed usage between DOM-optimised updates and conditional VDOM.

changeset-bot[bot] commented 3 months ago

đŸĻ‹ Changeset detected

Latest commit: 023c1405aefda63940be965c7fa149ca25a91f6d

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

This PR includes changesets to release 2 packages | Name | Type | | --------------------- | ----- | | @preact/signals | Minor | | @preact/signals-react | 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[bot] commented 3 months ago

Deploy Preview for preact-signals-demo ready!

Name Link
Latest commit 023c1405aefda63940be965c7fa149ca25a91f6d
Latest deploy log https://app.netlify.com/sites/preact-signals-demo/deploys/66fe4374f9034d0008c86b35
Deploy Preview https://deploy-preview-595--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 site configuration.

github-actions[bot] commented 3 months ago

Size Change: +268 B (+0.32%)

Total Size: 83.3 kB

Filename Size Change
docs/dist/basic-********.js 243 B -1 B (-0.41%)
docs/dist/demos-********.js 3.45 kB +2 B (+0.06%)
packages/preact/dist/signals.js 1.39 kB +128 B (+10.11%) ⚠ī¸
packages/preact/dist/signals.mjs 1.36 kB +139 B (+11.39%) ⚠ī¸
ℹī¸ View Unchanged | Filename | Size | | :--- | :---: | | `docs/dist/assets/bench.********.js` | 1.59 kB | | `docs/dist/assets/client.********.js` | 46.3 kB | | `docs/dist/assets/index.********.js` | 838 B | | `docs/dist/assets/jsxRuntime.module.********.js` | 284 B | | `docs/dist/assets/preact.module.********.js` | 4.03 kB | | `docs/dist/assets/signals-core.module.********.js` | 1.4 kB | | `docs/dist/assets/signals.module.********.js` | 2.02 kB | | `docs/dist/assets/style.********.js` | 21 B | | `docs/dist/assets/style.********.css` | 1.24 kB | | `docs/dist/nesting-********.js` | 1.13 kB | | `docs/dist/react-********.js` | 242 B | | `packages/core/dist/signals-core.js` | 1.45 kB | | `packages/core/dist/signals-core.mjs` | 1.47 kB | | `packages/react-transform/dist/signals-*********.js` | 5.03 kB | | `packages/react-transform/dist/signals-transform.mjs` | 4.27 kB | | `packages/react-transform/dist/signals-transform.umd.js` | 5.15 kB | | `packages/react/dist/signals.js` | 188 B | | `packages/react/dist/signals.mjs` | 150 B |

compressed-size-action

developit commented 1 month ago

We could also apply the same notification delay to the prop updater and the text updater to limit their DOM mutation frequency to screen refresh.

JoviDeCroock commented 1 month ago

@developit I'll follow up the changes to props/text separately