by pramodliv1 · 11y ago · 0 comments
>Do not use Backbone models
I use Backbone models for ajax since it makes decisions such as PUT vs POST and model.save() looks cleaner than $.ajax. Also, Backbone collections provide a declarative way to handle sorting and duplicate models. But these models are internal to the Store and not exposed to the views. I'm still a React newbie. Is this a valid reason to continue using Backbone?
2. It seems as though Khan Academy do not use React for SVG elements in their interactive exercises. For example, https://www.khanacademy.org/math/geometry/transformations/hs... Do you plan to migrate SVG to React?
2. We had a library originally written by Ben Alpert (now core react team) that handles all of our interactive svgs [1]. Since KA has a lot of legacy code there, and there hasn't been an immediate benefit to porting it (which would take a pretty significant time investment, on the [very roughly] order of a couple dev-months), this is still mutable jQuery/raphael code. There have been a lot of talks of eventually porting this to react, but the immediate need for it hasn't been there yet. However, I did write a React wrapper around much of this code which is used by newer interactive widgets [2].
[1]: https://github.com/Khan/khan-exercises/blob/master/utils/gra...
[2]: https://github.com/Khan/perseus/blob/master/src/components/g...
Backbone models are also mutable which means lots of model change listeners (callback soup) - check out the flame charts here [2] to get an intuition for what callback soup does to your code and how react fixes it.
[1] http://wingspan.github.io/wingspan-forms/examples/faceted-se... (json blob is the ui state) [2] http://swannodette.github.io/2013/12/17/the-future-of-javasc...
I can see argument against adding heft to your app, though - if that's something you're worried about. There's the ampersand library which tries to be more modular while reflecting the good parts of Backbone, but it seems to be going a bit quiet.
Apart from dirty-check for POST/PUT and uniqueness/sorting what other benefits could Backbone models have?
How do you expose your models to the view, I would guess you just serialise into regular objects?
Yes, I don't expose models to the components. I'm trying this on a side project. We are still using plain Backbone in production. So, I don't have experience with large scale React apps.
>> What other benefits could Backbone models have?
It also features like validation and other stuff like nested models built by the community.
>> How do you expose your models to the view, I would guess you just serialise into regular objects?
Yes!