0.0.4 • Published 9 years ago

@yuheiy/page-dispatcher v0.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
9 years ago

Page Dispatcher

Divide logic of JavaScript by your page.

Concept

Details are here (Japanese)

Installation

$ npm install --save @yuheiy/page-dispatcher

Usage

'use strict';

var PageDispatcher = require('@yuheiy/page-dispatcher');
var dispatcher = new PageDispatcher();

dispatcher.on('common', function () {
  // run on all pages
});

dispatcher.on('home', function (message) {
  // run only on home
  console.log(message);
});

window.run = dispatcher.run.bind(dispatcher);
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Home - Site Name</title>
  </head>

  <body>
    <h1>Home</h1>

    <script src="bundle.js"></script>
    <script>
      run('common');
      run('home', 'This is a home of this site.');
    </script>
  </body>
</html>