nerv
v0.3.0
Published
A tiny, pure, event-based model wrapper for the MVC or MDV (Model-driven Views) pattern
Downloads
22
Readme
NervJS
- A tiny, pure, event-based model wrapper for the MVC or MDV (Model-driven Views) pattern.
- It is far thinner than Backbone. None of View, Controller or Router is involved.
- Strict data hiding but straightforward way to use.
- Provides minimal built-in APIs but supports all external and conventional methods to access the model.
- Model can be nested and supports bubbling events.
In NodeJS
npm install nerv
In browser
AMD and OzJS
- NervJS can either be viewed as an independent library, or as a part of OzJS mirco-framework.
- It's wrapped as an AMD (Asynchronous Module Definition) module. You should use it with oz.js (or require.js or similar for handling dependencies).
- If you want to make it available for both other AMD code and traditional code based on global namespace. OzJS provides a mini define/require implementation to transform AMD module into traditional module pattern.
- See http://ozjs.org for details.
Get the code
- Download on Github
- Add to your project as new dependency:
Dependencies
Examples
API and usage
var nerv = require('nerv');
var papercover = nerv();
var hardcover = nerv({
isHard: true
});
var pageModel = nerv.model({
defaults: {
text: '',
number: 0
},
mark: function(){...}
});
var page = pageModel({ number: 1 });
var page2 = pageModel({ number: 2 });
page.get()
--page.get(key)
--page.set(key, function, context)
--page.set(key, value, context)
--page.set(key, model, context)
--page.set(function, context)
--page.set(model, context)
--page.remove(key)
--page.reset()
--page.find(value|model)
--
var book = nerv([]);
var bookB = nerv.collection({
selectPage: function(number){...}
});
book.add(value|model)
--- same as above
More References
Release History
License
Copyright (c) 2010 - 2013 dexteryy
Licensed under the MIT license.