Closed markijbema closed 10 years ago
:+1: I think these all make sense.
Thank you!
FWIW, I ran into the issues noted here: https://github.com/facebook/react/issues/1247 (referenced: https://github.com/usepropeller/react.backbone/issues/9). I was about to start slinging code around like I owned the place, but I checked the project's repo and found you already fixed it. Thanks again!
Extracting the Backbone view conversion code into its own mixin makes sense. I converted from Marionette to React/react.backbone with just the BackboneMixin from this pull request. I wouldn't use the view methods. Migrating from Backbone/Marionette to React involves a bit more than changing dependencies; it's worthwhile to commit completely to the React philosophy and recast the views in a completely React-ified light.
Superseded by #18
In this pull request I did several things.
I unified the behaviour for collections and models. both debounce their events now, and both support onModelChange.
Secondly, I unified some constructs. So guard statements are now all guard statements, instead of sometimes surrounding ifs for instance.
I extracted _subscribe and _unsubscribe. This means that if you add another mixin which defines _subscribe, or define _subscribe yourself, it will still work. This also means, it would conceptually be possible to mixin BackboneMixin multiple times.
I made the model mixin more similar to the other stuff mixed in. I extracted the 'view' methods, which make a component more like a backbone view, to a mixin. Now createbackboneClass only adds two mixins.
Other than that it's mostly small fixes.
I'm interested in discussing the choices in this. We need a class/mixin which provides binding for backbone models for react components. I personally think the 'view'-methods (getModel, model, el) aren't a good idea, and are mainly useful for conversion from Backbone Views to React Components. But when you are converted, they're only confusing, as they add non-standard stuff to react, while saving very little.
I'm not sure where you want to take the library, so I'm not sure if you like all the changes. If you disagree with me on the latter point, it might be better for me to start my own library, but I'd rather not (and I don't think at this point it's needed, as I just can use the mixin, and avoid using createBackboneClass).