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

optimizing static objects #390

Open
titoBouzout opened this issue Dec 24, 2024 · 2 comments
Open

optimizing static objects #390

titoBouzout opened this issue Dec 24, 2024 · 2 comments

Comments

@titoBouzout
Copy link
Contributor

Recording a possible optimization mentioned by Ryan in https://discord.com/channels/722131463138705510/1023298332338167919/1318648799719063693

this

<Comp inputProps={{ title: title(), name: name() }} /> 

becomes

createComponent(Comp, {
  get inputProps () {
    return { title: title(), name: name() }
  }
})

which could be improved to be

createComponent(Comp, {
  inputProps: {
    get title() {
      return title()
    }, 
    get name() {
      return name()
    }
  }
})

It would make reactivity more granular I think

@lxsmnsyc
Copy link
Collaborator

except that's only probably ideal if it's a Record. Imagine if it was the user's intent to create a new object instance, rather than be a reactive object.

@titoBouzout
Copy link
Contributor Author

Excellent note, I guess it is somewhat similar to

<Comp inputProps={title()} /> 

which becomes

<Comp inputProps={{get title(){ title() } } /> 

if the user wants it static they need to hoist it

const staticc = title() // reading signal 
<Comp inputProps={staticc} /> 

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

No branches or pull requests

2 participants