Subview.js – Views done right!
Subview.js is a minimalistic hierarchical view framework designed to be highly modular, highly extensible and very efficient for applications containing thousands of views. The last point makes subview an excellent choice for complex user interfaces that are redrawn often such as word processors, messengers and other single-page web-apps. Subview is not and will never be a complete MVC framework but rather a View/Controller module designed to be used in conjunction with a Data Model.
Features:
- Extensible Views
- Hierarchically Scoped Events
- Elegant Templating with Your Favorite Engine (Handlebars, Underscore, EJS or Jade)
- Efficient View Management Through Object Pools
- Self-Contained and Compatible Any Other Framework
- 3.4KB gzipped & 8.9KB minified
Installation
npm install subview
Basic Usage
;
A simple example is available here.
Philosophy
Duties:
- Render the application
- Execute functions that define UI logic
Store application stateMoved to the State Extension.Provide event bindings for application state changeProvide Event Bindings for inner-app communication.- Manage View Object pools
Tenets:
- App interfaces should be organized into a hierarchical sub-view structure.
- This hierarchy should be defined only in the current state of the DOM. i.e. a subview is defined as a view that is a child of view's wrapper DOM element.
- These views should all inherit a set of basic methods and properties.
- Views should support event broadcasting.
- Event listeners should be directional. i.e. listen to children, parents, siblings or global.
- Views should be recycled automatically using an Object Pool.
- Templating should be supported in such a way that it can be done both server side & client side.
- Given a DOM element, you should be able to get it's corresponding view.
- No magical re-rendering of templates or DOM changes. This is essential for high-performance apps where the developer wants to control every single DOM render.
- Views should be able to be extended while preserving critical functionality of their parent class.
Development
To build: grunt build
To watch: grunt watch
To test: grunt test
Contributing
Contributions are always welcome! Please list bugs, issues and feature requests here.