https://github.com/auchenberg/backbone.advices
Bringing Advices to Backbone
https://github.com/auchenberg/backbone.advices
Last synced: 8 months ago
JSON representation
Bringing Advices to Backbone
- Host: GitHub
- URL: https://github.com/auchenberg/backbone.advices
- Owner: auchenberg
- License: mit
- Created: 2012-09-09T18:25:15.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2012-09-10T09:27:51.000Z (about 13 years ago)
- Last Synced: 2025-01-06T18:36:48.235Z (9 months ago)
- Language: JavaScript
- Size: 118 KB
- Stars: 1
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
backbone.advices
===============Bringing Advices to Backbone.
I always missed "filters" from Railsin Backbone. So I spent a little time adding advices, known from [aspect-oriented programming](http://en.wikipedia.org/wiki/Advice_in_aspect-oriented_programming), which acts in a similar way.
The best way to describe backbone.advices, is by showing this example:
# Example
```javascript
var view = Backbone.AdvicesView.extend({// Syntax 1
beforeAdvices: ['ensureQuerystrings'], // -> Getting called before all methods.// Syntax 2
beforeAdvices: [{
'onBeforeRender' : { only : ['render'] }, // -> Getting called after render-method.
'getData' : { except : ['render'] } // -> Getting called after all methods except render-method.
}],afterAdvices: ['handleErrors'], // -> Getting called after all methods.
// Methods
render: function() {
// Render Logic
console.log('render');
},// Advices
getData: function() {
console.log('getData');
}handleErrors: function() {
console.log('handleErrors');
}});
```