track-controller

0.0.21 • Public • Published

TrackController

Controller for track. This controller is based on the Component of Mithril.js.

Build Status

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  
}

Readme

Keywords

none

Package Sidebar

Install

npm i track-controller

Weekly Downloads

0

Version

0.0.21

License

ISC

Unpacked Size

33 kB

Total Files

18

Last publish

Collaborators

  • alfa-jpn