-
Notifications
You must be signed in to change notification settings - Fork 13
Need a way to deal with objects changing state (i.e. arrays) #24
Comments
From @zetachang on May 3, 2015 5:56 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. |
From @catmando on May 4, 2015 18:51 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? |
From @zetachang on May 5, 2015 1:10 I think I get your point now, looks like a nice to have feature. Feel free to open up a pull request 👍 |
From @catmando on May 6, 2015 22:37 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 :-) |
From @zetachang on May 8, 2015 7:3 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. 😃 |
From @catmando on May 8, 2015 7:36 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 |
From @catmando on May 17, 2015 12:15 Okay.. I setup a WIP pull request... your comments on these items would be great. |
From @catmando on May 3, 2015 4:5
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!
Copied from original issue: zetachang/react.rb#24
The text was updated successfully, but these errors were encountered: