Skip to content
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

Fix force update after unmount #13

Closed

Conversation

markijbema
Copy link
Collaborator

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).

this is already checked in the guard
was redundant with documented code
changeOptions should only be declared once
to make style consistent with subscribe/unsubscribe,
which use similar constructs for checking preconditions
This way we will be able to mixin multiple times
@EtienneLem
Copy link
Contributor

👍 I think these all make sense.

also added use strict to ensure this won't happen again
used parameters instead of binding to this. Thanks to @EamonNerbonne for
the suggestion
@brandocalrissian
Copy link

Thank you!

FWIW, I ran into the issues noted here: facebook/react#1247 (referenced: #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.

@markijbema
Copy link
Collaborator Author

Superseded by #18

@markijbema markijbema closed this Apr 16, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants