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

state-of-the-art-javascript

 state-of-the-art-javascript

#stapy で話した JS 最前線の話です。

Yosuke Furukawa

July 12, 2017
Tweet

More Decks by Yosuke Furukawa

Other Decks in Programming

Transcript

  1. ࠓ೔࿩͢͜ͱ • Why React? • Why Redux? • Why Server

    Side Rendering? • Why Backend For Frontend? • Why Consumer Driven Development? • How do we create rich applications? 5W 1H Ͱ࿩͠·͢ɻ
  2. Flux • Flux͸Action => Dispatcher => Store ͱൃੜ ͨ͠ΠϕϯτΛܨ͍͖͛ͯɺ React

    ͷ view Λ ߋ৽͢ΔͨΊͷঢ়ଶɾΠϕϯτ؅ཧख๏ ϘλϯΫϦοΫ )551(&5 +40/ 4UPSFʹϚοϓ 4UPSF͕มߋ͞Ε ͨͷΛड͚ͯ 3FBDUߋ৽
  3. Redux • ఩ֶͱͯ͠͸̏ͭ • Singleton Store • State is read-only

    • (state, action) => newState ྑ͞Λཧղ͠Α͏ͱ͢Δͱؔ਺ܕͷ ߟ͑ํ͕͍ΔͷͰͱΓ͋͑ͣॻ͍ͯΈͨํ͕ૣ͍
  4. Redux • ͦΕͰ΋આ໌ͯ͠ΈΔ • Singleton Store • Storeʢͭ·Γ͸ঢ়ଶʣ͸͔̍ͭ͠ͳ͍ɺ͔͠΋৭Μͳॴ͔Β৮ΕΔΑ͏ʹͳ͍ͬͯ Δɻ •

    State is read-only • ঢ়ଶͷมߋ͸جຊతʹͰ͖ͳ͍ɺมߋ͢Δͷ͸ReducerͷΈɻ • (state, action) => newState • ͔͠΋ Reducer ͕΍ͬͯΔͷ͸ঢ়ଶͷ"มߋ"Ͱ͸ͳ͍ɻݫີʹ͸ɺ৽͍͠ঢ়ଶΛ࡞ͬͯ Ϛοϐϯά͢Δʹ౳͍͠ɻ಺༰Λॻ͖׵͚͑ͨͩͰ͸redux͸มߋͨ͠ͱೝΊͯ͘Ε ͣɺ৽͍͠ΦϒδΣΫτΛฦ͢ඞཁ͕͋Δ
  5. Redux • ͦΕͰ΋આ໌ͯ͠ΈΔ • Singleton Store • Storeʢͭ·Γ͸ঢ়ଶʣ͸͔̍ͭ͠ͳ͍ɺ͔͠΋৭Μͳॴ͔Β৮ΕΔΑ͏ʹͳ͍ͬͯ Δɻ •

    State is read-only • ঢ়ଶͷมߋ͸جຊతʹͰ͖ͳ͍ɺมߋ͢Δͷ͸ReducerͷΈɻ • (state, action) => newState • ͔͠΋ Reducer ͕΍ͬͯΔͷ͸ঢ়ଶͷ"มߋ"Ͱ͸ͳ͍ɻݫີʹ͸ɺ৽͍͠ঢ়ଶΛ࡞ͬͯ Ϛοϐϯά͢Δʹ౳͍͠ɻ಺༰Λॻ͖׵͚͑ͨͩͰ͸redux͸มߋͨ͠ͱೝΊͯ͘Ε ͣɺ৽͍͠ΦϒδΣΫτΛฦ͢ඞཁ͕͋Δ ؆୯ʹݴͬͯ͠·͑͹ঢ়ଶͷ௥੻͕͠΍͍͢ɻ ్த͔Βউखʹঢ়ଶ͕ॻ͖׵͑ΒΕΔ͜ͱ͕ͳ͍ͷͰ σόοά΋͠΍͍͢ʢredux-devtoolsʣ
  6. Redux • ͓લͷॻ͜͏ͱ͍ͯ͠ΔϩδοΫͱ͸Կͩ • UIϩδοΫʁ => React ʹ͔͚ • ۀ຿ϩδοΫ?

    => αʔόαΠυʹݴ͑ • ۀ຿ͱUIͷதؒʁ => BFF (ޙड़) • ڧ͍ͯ͋͛ΔͳΒίί͔ɾɾɾʁ ͜͜
  7. Client Server micro services Rich Single Page Web Apps with

    MicroServices 'SPOUFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT
  8. Client Server micro services Rich Single Page Web Apps with

    MicroServices 'SPOUFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT
  9. Client Server micro services Rich Single Page Web Apps with

    MicroServices 'SPOUFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT ͜͜Ͱ΍͍ͬͯΔ͜ͱɿ "1*ͷू໿ॲཧ "1*ϨεϙϯεΛ6*༻ʹՃ޻ "1*SFTQPOTF$BDIF $JSDVJU#SFBLFS FUD
  10. Client Server micro services Rich Single Page Web Apps with

    MicroServices 'SPOUFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT ΫϥΠΞϯτɿ ը໘ͱಈ͖Λ࡞Δɻ αʔόʔɿ ಠཱͨ͠ϏδωεϩδοΫΛ ఏڙ͢Δ
  11. Client Server micro services Rich Single Page Web Apps with

    MicroServices 'SPOUFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT ΫϥΠΞϯτɿ ը໘ͱಈ͖Λ࡞Δɻ αʔόʔɿ ಠཱͨ͠ϏδωεϩδοΫΛ ఏڙ͢Δ ͋ͱɺ૊৫ͷน
  12. Client Server micro services Rich Single Page Web Apps with

    MicroServices 'SPOUFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT
  13. Client Server micro services Rich Single Page Web Apps with

    MicroServices 'SPOUFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT Backend For Frontend #BDLFOE -PHJDT
  14. Client Server micro services Rich Single Page Web Apps with

    MicroServices 'SPOUFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT Backend For Frontend #BDLFOE -PHJDT ΫϥΠΞϯτ͸ຊདྷͷ6*૚ͷ ॲཧʹ஫ྗͰ͖Δ
  15. Client Server micro services Rich Single Page Web Apps with

    MicroServices 'SPOUFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT Backend For Frontend #BDLFOE -PHJDT ը໘Λߏங͢Δखॿ͚Λ͢Δ "1*ฒྻݺͼग़͠ $BDIF΋ͨ͘͞Μ࣋ͯΔ 'JMF6QMPBE8FC4PDLFUFUD
  16. Client Server micro services Rich Single Page Web Apps with

    MicroServices 'SPOUFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT Backend For Frontend using Node.js #BDLFOE -PHJDT <13>͜͜Λ/PEFKT ʹ͢Δͱ΋ͬͱ৭ΜͳϝϦοτ͕
  17. Client Server micro services Rich Single Page Web Apps with

    MicroServices 'SPOUFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT Ұ෦ͷ'SPOUFOE-PHJDΛڞ ௨ԽͰ͖Δ 'SPOUFOE -PHJDT Backend For Frontend using Node.js
  18. Client Server micro services Rich Single Page Web Apps with

    MicroServices 'SPOUFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT #BDLFOE -PHJDT ը໘ͷWBMJEBUJPO )5.-ੜ੒FUD 'SPOUFOE -PHJDT Backend For Frontend using Node.js
  19. Why Backend For Frontend? • υϝΠϯಛԽͨ͠αʔϏεͱϦονͳΫϥΠΞϯτΛܨ͙ௐఀ໾ • ը໘Λ࡞ΔͨΊͷิࠤΛ͢Δ • APIͷ·ͱΊ໾

    • Cache΋͜͜ͷ૚Ͱ΍ΔͱBackend Friendly • BFF Λ Node.js ʹ͢Δͱ͞Βʹ • ϑϩϯτͷ࡞ۀΛڞ௨ԽͰ͖Δ • Server Side Rendering / validation logic etc
  20. 7 principles of Rich Web Applications • socket.io ͷ࡞ऀ •

    Guillermo Rauch ࢯఏএ • ຋༁ • http://yosuke-furukawa.hatenablog.com/entry/2014/11/14/141415
  21. ·ͱΊ • Why React? • ίϯϙʔωϯτࢦ޲ʹϚονͤͨ͞ແཧແବͷগͳ ͍ϥΠϒϥϦ • Ծ૝DOM͕͋Δ͜ͱͰࡶʹϨϯμϦϯάͯ͠΋໰ ୊͕ͳ͍Α͏ͳઃܭʹɻ

    • Why Redux? • ϑϩϯτΤϯυͷঢ়ଶΛ؅ཧ͢ΔͨΊͷϥΠϒϥϦ • ը໘ͷ৘ใΛҰՕॴͰ؅ཧ͢Δ͜ͱͰDOMͷ৘ใ ʹཔΒͳ͍ઃܭ͕Մೳʹ • Why Server Side Rendering? • ॳظදࣔߴ଎Խ • SEO • Why BFF? • Microservices Խ͞ΕͨΞʔΩςΫ νϟʹରͯ͠ͷϨΠϠϦϯά • Why Consumer Driven Contract? • ΫϥΠΞϯτ͔Β࢖ΘΕΔAPIΛܾ ΊΔͱ͍͏੍໿ • How do we create rich apps? • ϑϨʔϜϫʔΫ • ΨΠυϥΠϯ