define(['jquery', ‘backbone’, ‘utils/resizeTextareaUtil’],
function ($, Backbone, ResizeUtil) {
return Backbone.View.extend({
el: 'form',
events: {
'keyup #note': 'resizeTextAreaField',
'blur #note': 'hideTextAreaCounters'
},
// Resize text area as user types
resizeTextAreaField: ResizeUtil.resizeField,
// Update textarea counter with remaining character left
hideTextAreaCounters: ResizeUtil.hideTextArea,
};
});
We now have moved our business logic into a vanilla file called
resizeTextAreaUtil. We can easily require that into this file, and still bind
this with BB events. We can also easily require that into a React component and
bind that to some React event. This can now be used in future framework versions
without having to change.
Reality: If you don't build a barrier, your legacy React code in 2 years will be
just as painful to migrate as your current legacy BB code is now.
So you’ve made it easier to change. What’s left? How do you convince people?