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

Disallow side-effects in computed #231

Merged
merged 7 commits into from
Mar 11, 2023

Conversation

eddyw
Copy link
Contributor

@eddyw eddyw commented Oct 5, 2022

Description

From Slack discussion, this PR disallows side-effects in computed. That is, setting signal's values:

const c = computed(() => a.value++)

I used a bit flag instead of instanceof operator because it's faster to check if a bit is set than walking the prototype to lookup for a constructor. I initially thought to add a new _type property to Signal but it also seems a waste of space/memory if it's only used to check if a Signal is a computed type.

@changeset-bot
Copy link

changeset-bot bot commented Oct 5, 2022

🦋 Changeset detected

Latest commit: aec5d0b

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
Copy link

netlify bot commented Oct 5, 2022

Deploy Preview for preact-signals-demo ready!

Name Link
🔨 Latest commit aec5d0b
🔍 Latest deploy log https://app.netlify.com/sites/preact-signals-demo/deploys/640c71ba158ac50008993382
😎 Deploy Preview https://deploy-preview-231--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 settings.

@JoviDeCroock JoviDeCroock merged commit 862d9d6 into preactjs:main Mar 11, 2023
@github-actions github-actions bot mentioned this pull request Mar 11, 2023
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.

None yet

2 participants