ngBackbone is a small extension of Backbone.js that unlocks Angular-like programming experience
Well, I love old good Backbone for its simplicity and flexibility. However after working with such frameworks as Angular and React, I see that Backbone app requires much more code. Yet I don't want to ditch Backbone and deal with some 20K LOC framework codebase. I just want a minimal modular extension that will improve my programming experience and maintainability of my code.
And that is how I came up with
- Angular inspired live templates via ngTemplate
- Separation of declarative (@Component + template) and imperative programming
- 1-way and 2-way binding
- Testable views
- Control over nested views
- Asynchronous form validators (e.g. server-side validation)
- Debauncable form validators
- Fluent TypeScript programming experience
What does it do?
ngBackbone extends the base with:
- @Component decorator encapsulates declarative from imperative part of the view
- View module binds specified models/collections to the view template (makes the template reacting on data events)
- FormView creates state models for controls per a specified group and binds them to input/change event. FormView keeps these models in sync with element ValidityState and can run custom validators on input events.
Ng.Backbone does not depend on jQuery or Underscore, meaning you can use on an optimized build of Backbone. For example,
my preferred build consists of Exoskeleton (Backbone decoupled from Underscore), Backbone.NativeView (Backbone View decoupled from jQuery) and
Backbone.Fetch (Backbone.sync leveraging Feth API instead of XHR)
Ng.Backbone works fine with canonical Backbone bundle (Backbone + jQuery + Underscore)
What does it look like?
- Getting Started
- Template syntax
- @Component Decorator
- View Module
- FormView Module
ngBackbone welcomes maintainers. There is plenty of work to do. No big commitment required,
if all you do is review a single Pull Request, you are a maintainer.
How to set up
How to run tests
npm run test