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

Mutable instance captures #3

Open
Tamschi opened this issue Oct 5, 2020 · 1 comment
Open

Mutable instance captures #3

Tamschi opened this issue Oct 5, 2020 · 1 comment
Labels
type: feature Brand new functionality, features, pages, workflows, endpoints, etc.

Comments

@Tamschi
Copy link
Owner

Tamschi commented Oct 5, 2020

If a field should be modified, that's usually written as |value = RefCell::<i32>::new(initial)|; or similar.
(Technically using an atomic would be better in this case, but that's more verbose elsewhere.)

It should be possible to declare mutable instance fields more quickly, for example like so |mut value: i32 = {initial}|.

I haven't yet looked into the implications of adding a feature like this. Components with mutable fields would probably have to contain a RefCell instance, or alternatively I could confine mutable components to the current thread (which wouldn't be a big loss, since Asteracea targets primarily the single-threaded web platform in terms of rendering and event handlers shouldn't have to be Send or Sync either).

@Tamschi Tamschi added the type: feature Brand new functionality, features, pages, workflows, endpoints, etc. label Oct 5, 2020
@Tamschi Tamschi changed the title Mutable captures Mutable instance captures Oct 5, 2020
@Tamschi
Copy link
Owner Author

Tamschi commented Jan 12, 2021

This should use Cell, not RefCell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature Brand new functionality, features, pages, workflows, endpoints, etc.
Projects
None yet
Development

No branches or pull requests

1 participant