-
Notifications
You must be signed in to change notification settings - Fork 155
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
Replace functions with Signal type #20
Conversation
I don't really like combing I like having For consistency, there should also be a method on Edit: |
Actually, I just realized that we can do one better than a function call - just have it implement |
Would that really be better? That makes the dependency tracking a lot more implicit and people could get confused on what gets tracked and what does not. Making it a function call immediately signals to the user that something is happening other than simply accessing state. |
Actually, that's true - and trying to implement it I realized that it actually wouldn't work :D. I'll try to implement a function call then - although I will point out that |
The problem with making it callable is that I'm pretty sure it would basically require storing an |
I guess you're right. We'll use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation looks really good. I like how some functionality is separated into the create_selector_with
function.
I've removed the |
Essentially I swapped out using
Rc<dyn Fn() -> Rc<T>>
getters for theStateHandle<T>
type, and I swapped outRc<dyn Fn(T)>
signal setters for theSignal<T>
type. The functions have been replaced with.get
/.set
methods - although this is slightly longer, it also has other advantages such as being able to use.get_untracked
instead of theuntracked
function, which is shorter and faster (since it doesn't access thread locals at all).Fixes #14.