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

WordPressユーザーのためのAngular & Progressive Web Appsの話

WordPressユーザーのためのAngular & Progressive Web Appsの話

Yosuke Onoue

October 09, 2016
Tweet

More Decks by Yosuke Onoue

Other Decks in Technology

Transcript

  1. ࣗݾ঺հ • ͓ͷ͏͑ (@_likr) • ژ౎େֶ ֶࡍ༥߹ڭҭݚڀਪਐηϯλʔ
 ੓ࡦͷͨΊͷՊֶϢχοτ ಛఆॿڭ •

    ng-kyotoΦʔΨφΠβʔɺGDGਆށελοϑ • ՄࢹԽɺ࠷దԽɺΞϧΰϦζϜͷݚڀ • WordPressॳ৺ऀ
  2. ࠓ೔ͷ࿩ • WP REST APIͷ࿩͸Ԭຊ͞Μ͕͍ͯ͠Δ͸ͣ… • ϑϨʔϜϫʔΫͷ࢖͍ํ΋طʹઆ໌͞Ε͍ͯΔ͸ͣ… • Progressive Web

    AppsͱAngularͷ࿩Λ௨ͯ͡ɺ
 ࡢࠓͷϑϩϯτΤϯυٕज़͕ɺࠓͲ͜΁޲͔͓͏ͱ
 ͍ͯ͠Δͷ͔Λͬ͘͟Γ঺հ͢Δ • ͜Ε͔ΒϑϩϯτΤϯυΛ࢝ΊΔਓ͕͙͢ʹ࠷৽ͷ
 τϨϯυΛऔΓೖΕΔͨΊͷπʔϧ΋঺հ
  3. PWAͰͰ͖Δ͜ͱ • ΦϑϥΠϯԽ • Πϯλʔωοτ઀ଓͳ͠Ͱͷར༻ • දࣔͷߴ଎Խ • Push௨஌ •

    ΞϓϦ΁ͷ࠶๚Λଅਐ • App Install Banner • ϗʔϜը໘΁ͷγϣʔτΧοτ௥Ճ • ঃʑʹΞϓϦͷΑ͏ʹͳΔʂ
  4. ؔ࿈Ωʔϫʔυ • Responsive Design • RAIL Performance Model • Web

    Storage / IndexedDB • ϞδϡʔϧγεςϜ • webpackɺSystemJSɺrollup.jsɺ… • ϑϩϯτΤϯυϑϨʔϜϫʔΫɺϥΠϒϥϦ • AngularɺPolymerɺReactɺ…
  5. Service Workerͱ͸ • Webϖʔδ(ϝΠϯεϨουɺUIεϨου)ͱ͸
 ಠཱͯ͠εΫϦϓτΛಈ࡞ͤ͞Δ࢓૊Έ • ωοτϫʔΫϦΫΤετΛϑοΫ • ΩϟογϡΛ࢖ͬͯϨεϙϯε •

    ϦΫΤετΛमਖ਼ • αʔόʔPushΛड͚ͯ௨஌Λදࣔ • postMessageͰϝΠϯεϨουͱ௨৴ • HTTPSͰͷΈಈ࡞ (localhostΛআ͘)
  6. ͳͥΦϑϥΠϯWebΞϓϦʁ • ϞόΠϧ؀ڥ΁ͷରԠ • ௨৴ͷෆ҆ఆ͞ • ௨৴ͷޮ཰Խ • ޫ଎౓͸ෆมʂ •

    ΦϑϥΠϯɾϑΝʔετͷࢥ૝ͱ࣮ફ by നੴढ़ฏ
 http://www.slideshare.net/shumpei/thought-and- practice-of-offline-first
  7. Fetchઓུ • The offline cookbook
 https://jakearchibald.com/2014/offline-cookbook/ • Cache only •

    Network only • Cache, falling back to network (cache first) • Cache & network race (fastest) • Network falling back to cache (network first) • …
  8. Angular 2.0ͷಛ௃ • ύϑΥʔϚϯε • ޮ཰ྑ͍มߋݕ஌ • AoTίϯύΠϧ • ҆શੑ

    • TypeScript࠾༻ʹΑΔܕαϙʔτ • ςετϑϨϯυϦʔͳAPI (DI) • ੜ࢈ੑ • ϑϧελοΫϑϨʔϜϫʔΫ
  9. Կނ Angular ? • εέʔϥϒϧ • ϋΠύϑΥʔϚϯεɺνʔϜ։ൃ • ް͍ίϛϡχςΟ૚ •

    ׆ൃͳ։ൃɺଟ਺ͷϢʔβʔ • Webඪ४Λҙࣝͨ͠API • ShadowDOMɺObservableɺZonesɺ… • ਺೥ઌ΋ઓ͑Δٕज़Λ਎ʹ͚ͭΔʂ
  10. Angular CLI • CLI tool for Angular2 • https://github.com/angular/angular-cli •

    Ͱ͖Δ͜ͱ • Component΍Service౳ͷੜ੒ • Ϗϧυ • ϩʔΧϧαʔόʔͷىಈ • σϓϩΠ(GitHub Pages) • …
  11. Hello World $ npm install -g angular-cli $ ng new

    hello-angular $ cd hello-angular $ ng serve
  12. ΍ͬͯΈͨ • Angular & WordPress.com APIͰ࣮૷ͨ͠ϒϩά • https://likr.github.io/blog • https://github.com/likr/blog

    • ΍ͬͨ͜ͱ • Service WorkerʹΑΔΦϑϥΠϯରԠ • sw-precache࢖༻ • هࣄ͸network firstͰऔಘ • ϗʔϜεΫϦʔϯ΁ͷ௥Ճ
  13. ߏ੒ • Angular 2.0 & Angular CLI • WordPress.com REST

    API • https://developer.wordpress.com/docs/api/ • Pure.css • http://purecss.io/ • sw-precache • https://github.com/GoogleChrome/sw-precache • GitHub Pages
  14. ࢀߟ৘ใ • for Angular 1
 https://github.com/likr/wpapi-angular-example • for Angular 2


    https://github.com/likr/wpapi-angular2-example
 https://github.com/likr/blog