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

"effects" in cellx #49

Closed
trusktr opened this issue Aug 16, 2022 · 2 comments
Closed

"effects" in cellx #49

trusktr opened this issue Aug 16, 2022 · 2 comments

Comments

@trusktr
Copy link

trusktr commented Aug 16, 2022

In Solid, it is:

createEffect(() => {
  console.log(firstName() + ' ' + lastName())
})

I suppose in cellx the same is a cellx but just don't use the value:

cellx(() => {
  console.log(firstName() + ' ' + lastName())
})

So "effects" and "signals" are under a single API. Personally I prefer dependency-tracking effect patterns of subcription or event patterns because the automatic dependency tracking is what leads to concise and clean code; otherwise having to manage subscriptions/events gets more verbose and less flexible, similar to always using on in Solid. (Article coming soon on how dependency tracking simplifies code compared to repeated promises, subscriptions, and events).

@Riim
Copy link
Owner

Riim commented Aug 17, 2022

import { autorun } from 'cellx';

const dispose = autorun(() => {
  console.log(firstName() + ' ' + lastName());
});

firstName('SomeName');

dispose();

@trusktr
Copy link
Author

trusktr commented Aug 17, 2022

Ah nice. I was going off of only the README.md.

@trusktr trusktr closed this as completed Aug 17, 2022
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