-
Notifications
You must be signed in to change notification settings - Fork 35
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
Need a way to deal with objects changing state (i.e. arrays) #24
Comments
Thanks for pointing this out, I think this could be a common mistake given that the original Currently, you can write as below, def add_friend(friend)
self.foo = foo << friend; self
end To get the benefit of brevity and also make it chainable. |
I understand that the current solution is to do something like you said above... My intention is to add a solution that will read cleaner and be shorter. I have implemented the all the solutions suggested above, and after playing with them in some code feel that just adding the foo! method is the easiest and cleanest. I.e. If I do a pull request with this will you accept it? |
I think I get your point now, looks like a nice to have feature. Feel free to open up a pull request 👍 |
i've made some more improvements to this... expect a pull request soon, but first I am integrating with some real code to see how everything feels. Basically there is now a In addition I added two class methods I.e. Finally if the type of parameter is
then
will send 1,2,3 to whatever Proc foo got bound to. Altogether these changes clean things up so that things read really nicely. Oh yeah two other things: You can say And any class that responds to 'render' can be used in the rendering dsl. So you can say div do
my_component param_1: 'Joe', param_2: 'Fred'
end As long as an instance of MyComponent responds to render... How does all that sound :-) |
Hey, thanks for taking time making this suggestion.
How is this going to be implemented? A wrapper object which will delegate all method invocations?
We currently got a params do
requires :foo, type: Proc, accessor: true
end
This is actually quite neat, 👍 on this.
Would you mind elaborating more on why having a base class rather than current module approach? The initial design decision made is to allow every Ruby class got render defined could be valid component.
👍 on this. Last but not least, would you mind open separate pull requests for these features? Thus we can review and merge them faster. 😃 |
Thanks for the feedback... will discuss more on the pull request. As I am using this in a real app, I am making adjustments to the API as I go |
Okay.. I setup a WIP pull request... your comments on these items would be great. |
@catmando This is implemented as part of the state observer (! bang method) API. Right? |
This issue was moved to ruby-hyperloop/hyper-react#24 |
For example
This does not work as
foo << friend
updates the array object, but there is no way to know that the foo state has been updated.I have implemented a couple of solutions, and am interested in which people would prefer:
foo = foo
to indicate a state change. This would return self so that the methods could be chainedor
2b) In addition the Proc class can be updated so this works
Just looking for people's input, preferences, or other ideas!
The text was updated successfully, but these errors were encountered: