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

ES7 Decorators

OKUNOKENTARO
September 29, 2015

ES7 Decorators

第60回HTML5とか勉強会 - ECMAScript 2015 & 2016での発表に使用した資料です

OKUNOKENTARO

September 29, 2015
Tweet

More Decks by OKUNOKENTARO

Other Decks in Programming

Transcript

  1. Decoratorsͱ͸? class Person { @nonenumerable get kidCount() { return this.children.length;

    } } function nonenumerable(target, name, descriptor) { descriptor.enumerable = false; return descriptor; } https://github.com/wycats/javascript-decorators#detailed-design
  2. ES7 Decorators • 2015೥9݄ݱࡏɺECMA262 Proposals Stage 1 • ෳ਺ͷProposalsʹؔ༩͍ͯ͠ΔYehuda Katz

    (wycats) ࢯͱɺ MicrosoftࣾͷJonathan Turnerࢯ͕ࡦఆͷத৺ͱͳ͍ͬͯΔ • BabelͰར༻Մ
  3. ࢖͍ํ • Babel • babel --optional es7.decorators • TypeScript •

    tsc --experimentalDecorators • ·ͩ྆ํͱ΋࣮ݧஈ֊ѻ͍ͰΦϓγϣϯ͕ඞཁ
  4. Angular 2 • ϑϨʔϜϫʔΫ"AngularJS"ͷ࣍ظϝδϟʔόʔδϣϯ • API͸AngularJS 1ܥ͔Βେ෯ʹมߋ • ৽APIͰ͸౰વͷΑ͏ʹDecoratorsߏจ͕૊Έࠐ·Ε͍ͯΔ •

    Microsoftࣾ TypeScript։ൃνʔϜͱ࿈ܞ͍ͯ͠Δ • Decoratorsߏจ͕ʢଟগͷमਖ਼͸͋ΕͲʣഇҊʹͳΔ͜ͱ ͸ແ͍ͱΈ͍ͯΔ
  5. core-decorators.js • https://github.com/jayphelps/core-decorators.js ɾ • DecoratorsߏจΛϑϧ׆༻ͨ͠ϥΠϒϥϦू • @readonly, @override, @deprecate,

    @debounceͳͲ
 ໿10छྨ͕༻ҙ͞Ε͍ͯΔ • ͜ͷOSS΍ɺଞݴޠͰͷDecoratorsߏจͷ࢖ΘΕํͳͲ΋
 ࢀߟʹ͢Δͱࣗ࡞͠΍͘͢ͳΔ͸ͣ
  6. wrasse • https://github.com/chatwork/wrasse ɾ • npm i -S wrasse ɾ

    • ChatWorkࣾॳͷnpm OSSͱͳΓ·ͨ͠ • ࣾ಺ίʔυωʔϜʹڕͷ΋ͷ͕͋ͬͨͨΊɺؔ࿈ͤ͞Α͏ • ೔ຊޠͰ͸ϕϥɺ۝भͰ͸ΫαϏͱ΋ݺ͹ΕΔڕ • ϫοηʔͱ͔ϥοηʔͱ͔ϫογϣΠͱ͔޷͖ʹݺ΂͹͍͍
  7. • ࣮૷಺Ͱ͸XSJOKFDU Ͱએݴ͢ΔͱɺUIJT͔ΒऔಘͰ͖Δ JNQPSUXSGSPNSFHJTUFSEFQFOEFODJFT JNQPSU\ $PNQPOFOU"  $PNQPOFOU# ^GSPNNPEVMFLFZT !XSJOKFDU

    \ֿֿח%FDPSBUPST圓俑 $PNQPOFOU" ؗ٦׾&4䕎䒭ך0CKFDUד♷ִ׷\BB CC^׾\B C^ה剅ֽ׷װא $PNQPOFOU# ^  FYQPSUEFGBVMUDMBTT"QQMJDBUJPO\ DPOTUSVDUPS \ DPOTPMFMPH UIJT$PNQPOFOU" 呓秛幥׫ ^ ^ ࢖͍ํ 4/5
  8. • ςετ಺Ͱ͸CFGPSF&BDIͳͲͰ湫䱸4FU EFTDSJCF *OKFDUNPDL  \ CFGPSF&BDI \ ٌحؙ䊴׃剏ִ "QQMJDBUJPOQSPUPUZQF$PNQPOFOU#.PDL$PNQPOFOU#

    ^  JU TIPVMECFJOKFDUFE.PDL$PNQPOFOU$  \ DPOTUBQQOFX"QQMJDBUJPO  BQQ$PNQPOFOU$.PDL$PNQPOFOU$JUⰻד׮〳 ^  ^  ࢖͍ํ 5/5
  9. એ఻ • AngularϢʔβάϧʔϓ ng-kyoto ͷୈࡾճͱͳΔMeetup͕
 ։࠵ܾఆ • ng-kyoto Angular Meetup

    #3 ɾ • 2015೥11݄22೔ʢ೔ʣ • ։࠵஍͸બఆதɺ͓ͦΒ͘ژ౎ࢢ಺ • ਖ਼ࣜͳࠂ஌ɺืू։࢝͸10݄தΛ༧ఆ • ΈΜͳདྷͯͶ