10000 Refine signal function overloads by wooloo26 · Pull Request #695 · preactjs/signals · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Refine signal function overloads #695

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

wooloo26
Copy link
@wooloo26 wooloo26 commented Jun 7, 2025

No description provided.

Copy link
changeset-bot bot commented Jun 7, 2025

🦋 Changeset detected

Latest commit: 7a01dee

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 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
netlify bot commented Jun 7, 2025

Deploy Preview for preact-signals-demo ready!

Name Link
🔨 Latest commit 7a01dee
🔍 Latest deploy log https://app.netlify.com/projects/preact-signals-demo/deploys/6843b7fdbc031700080a5865
😎 Deploy Preview https://deploy-preview-695--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.

@rschristian
Copy link
Member

What does this allow you to do that you couldn't otherwise?

@wooloo26
Copy link
Author
wooloo26 commented Jun 7, 2025

This change itself makes no difference to the user. The issue lies in the inconsistency between direct assignment of the optional parameter value and the behavior of the getter, which is a problem in the development implementation. I chose not to modify these aspects because I considered whether they might reflect some special intention by the developers.

declare class Signal<T = any> {
        // optional value
	constructor(value?: T, options?: SignalOptions<T>);
	get value(): T;
}

function Signal(this: Signal, value?: unknown, options?: SignalOptions) {
	this._value = value;
}

Object.defineProperty(Signal.prototype, "value", {
	get(this: Signal) {
		const node = addDependency(this);
		if (node !== undefined) {
			node._version = this._version;
		}
		return this._value;
	}
	...
})

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
0