0.0.21 • Published 7 years ago

track-controller v0.0.21

Weekly downloads
2
License
ISC
Repository
github
Last release
7 years ago

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  
}
0.0.21

7 years ago

0.0.20

7 years ago

0.0.19

7 years ago

0.0.18

7 years ago

0.0.17

7 years ago

0.0.16

7 years ago

0.0.15

7 years ago

0.0.14

7 years ago

0.0.13

7 years ago

0.0.12

7 years ago

0.0.11

7 years ago

0.0.10

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago