component / reactive

Tiny reactive template engine
383 stars 48 forks source link

Refactor #77

Closed jkroso closed 10 years ago

jkroso commented 11 years ago

looks like the lib has changed a lot since it was first written and perhaps become a bit messy. I just had a go at tidying it up. Mostly I've just re-organized the Binding classes then once I had done that I realised most of the utilities were for the binding classes so moved them all into the base binding class. Anyway I think its a fair bit simpler now. Anyone up to do some reviewing?

jkroso commented 11 years ago

I'm just thinking we are probably better to arrange the bindings around the string types rather than how they are used. e.g. instead of have an attrBinding class with polymorphism inside the methods to handle the different string types we would be better to have an InterpolationBinding class with polymorphism coming from it having a specialised set of methods. Since its pretty trivial to then wire them up to either an attr or a text node I think it'll be a lot simpler.

jkroso commented 11 years ago

that worked pretty well. I was going to use functions to implement attrBinding and textBinding but they are always interpolated so I just left them as classes and switched them to inheriting from the interpolatedBinding class. If anyone is wondering why bother reorganising these classes its just to clarify how they are similar and how they are different. The thing that helped me the most was probably just moving the utilities inline though. haha

ianstormtaylor commented 11 years ago

+1 to trying to organize the bindings better and for reducing the size of utils in general