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

Proposal bind shorthand #37

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

Proposal bind shorthand #37

wants to merge 4 commits into from

Conversation

cesarParra
Copy link
Owner

No description provided.

}
}

function $binded(component: Record<string, object>, propertyName: string) {
Copy link
Owner Author

Choose a reason for hiding this comment

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

Rename to just bind (or bound)

Copy link
Collaborator

Choose a reason for hiding this comment

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

go with bind it's pretty standard

import { counter, counterPlusTwo } from "c/demoSignals";

export default class CountTracker extends LightningElement {
bindTest = $binded(this, "bindTest").to(counter);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I understand why you are doing this but I don't love it. Not sure what would be a better way to do the binding

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yeah, that's why I'm keeping it as a proposal stage until I get some feedback, not sure if you saw the issue I put up for discussion: #38

I don't want to merge if its going to be detrimental compare to what exists today, but I haven't found a better way of doing it with how Javascript works today. The only way I can think this could be done is by using decorators, but JS doesn't support those yet.

this.propertyName = propertyName;
}
to(signal) {
$effect(() => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this ok performance wise?

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