0.0.21 • Published 6 years ago
track-controller v0.0.21
TrackController
Controller for track. This controller is based on the Component of Mithril.js.
Installation
npm
npm install track-controller
Usage
const TrackController = require('track-controller');
class HogeController extends TrackController {
static definer() {
name('hoge'); // Define model name. **Required**
}
}
TrackController is usable TrackComponent interfarce.
Before/After action
const TrackController = require('track-controller');
class HogeController extends TrackController {
static definer() {
name('hoge');
before_action('loadHoge');
after_action('validateHoge');
}
loadHoge() {
// Call before loading prosess.
}
validateHoge() {
// Call after loading prosess.
}
}
cycile
[constructor]
|
[oninit]
|
| ----- [before_action] // if has cache, not call `before_actions`
| |
| ----- [after_action]
|
[oncreate]
ExceptionHandling
Raise error
class HogeController extends TrackController {
loadHoge() {
this.raise(404, 'NotFound'); // Raise error.
}
}
Lifecycle methods
Must call super method When override lifecycle method.
onparamschange
The onparamschanged()
hooks is called after change controller params.
// When change from `?hoge='aaa'` to `?hoge='bbb'`
onparamschanged(newly, older) {
// call
}
0.0.21
6 years ago
0.0.20
6 years ago
0.0.19
6 years ago
0.0.18
6 years ago
0.0.17
6 years ago
0.0.16
6 years ago
0.0.15
6 years ago
0.0.14
6 years ago
0.0.13
6 years ago
0.0.12
6 years ago
0.0.11
6 years ago
0.0.10
6 years ago
0.0.9
6 years ago
0.0.8
6 years ago
0.0.7
6 years ago
0.0.6
6 years ago
0.0.5
6 years ago
0.0.4
6 years ago
0.0.3
6 years ago
0.0.2
6 years ago
0.0.1
6 years ago