Upgrade to Pro — share decks privately, control downloads, hide ads and more …

AngularJS 1.3にBrowserify組み合わせてイベント駆動にした話

AngularJS 1.3にBrowserify組み合わせてイベント駆動にした話

ng-japan 2015年3月21日発表分の資料をSlideShareより再掲。
http://www.slideshare.net/armorik83/ng-japan

OKUNOKENTARO

March 21, 2015
Tweet

More Decks by OKUNOKENTARO

Other Decks in Programming

Transcript

  1. Use only directive • Each .ts file has one directive

    • Towards 2.0, I DON'T use service, factory, ng-controller
  2. Isolate Scope & broadcast • Use only Directive's isolate scope

    • Use only $broadcast() • But event names scattered
 Πϕϯτ໊จࣈྻ͕ࢄΒ͹Δ…
  3. Add Listener import Store = require('./store'); class DirectiveController { constructor()

    { Store.addListener(this.someMethod); } } ! class Store { addListener(listener) { this.$rootScope.$on(EVENT_NAME, listener); } ! hasChanged(err) { this.$rootScope.$broadcast(EVENT_NAME, err); } } Gather into one class ✌️
  4. Respect for F... • An Architecture F...
 Action -> Dispatcher

    -> Store -> View • My Angular 1.3 Project
 Child Directive Controller -> Dispatcher
 -> Store -> Root Directive • Without ng-controller, Angular DI, service, factory. Browserify is helpful us.