フロントエンドエンジニアが伝えたい最近の事情

1bf676e4bd36a48bf616c82d6f52c83a?s=47 sota ohara
July 14, 2018
16k

 フロントエンドエンジニアが伝えたい最近の事情

2018-07-14 PHPカンファレンス関西

1bf676e4bd36a48bf616c82d6f52c83a?s=128

sota ohara

July 14, 2018
Tweet

Transcript

  1. 2.

    about me Sota Ohara / sottar Mercari, Inc. Software Engineer

    Web, JavaScript, React Sell, mercari NOW, CSTool @sottar_ sottar
  2. 5.

  3. 7.
  4. 11.

    JavaScript ͷ᠘̍ var hoge = ‘global’; function foo() { console.log(hoge);

    // global? local? if (true) { var hoge = ‘local’; console.log(hoge); // global? local? } } foo();
  5. 12.

    JavaScript ͷ᠘̍ var hoge = ‘global’; function foo() { console.log(hoge);

    // undefined if (true) { var hoge = ‘local’; console.log(hoge); // local } } foo();
  6. 13.

    JavaScript ͷ᠘̍ var hoge = ‘global’; function foo() { var

    hoge; console.log(hoge); // -> undefined if (true) { var hoge = ‘local’; console.log(hoge); // -> local } } foo(); ࣮ࡍͷΤϯδϯͰ͸͜͏͍͏ղऍʹͳΔ ม਺ͷר্͖͛
  7. 14.

    JavaScript ͷ᠘̎ var Person = function(name){ this.name = name; };

    Person.prototype.sayName = function(){ console.log(this.name); // sottar? var hoge = function() { console.log(this.name); // sottar? }(); }; var sottar = new Person(‘sottar’) sottar.sayName();
  8. 15.

    JavaScript ͷ᠘̎ var Person = function(name){ this.name = name; };

    Person.prototype.sayName = function(){ console.log(this.name); // sottar var hoge = function() { console.log(this.name); // undefined }(); }; var sottar = new Person(‘sottar’) sottar.sayName();
  9. 16.

    JavaScript ͷ᠘̎ var Person = function(name){ this.name = name; };

    Person.prototype.sayName = function(){ console.log(this.name); // this -> Person var name = function() { console.log(this.name); // this -> Global Object }(); }; var sottar = new Person(‘sottar’) sottar.sayName(); UIJTͷࢦ͍ͯ͠Δ΋ͷ͕ҟͳΔ
  10. 17.

    JavaScript ͷ᠘̏ '' == false; '' === false; 9 +

    '1'; 9 - '1'; null == undefined 0.1 + 0.2 == 0.3; . . .
  11. 18.

    JavaScript ͷ᠘̏ '' == false; // true '' === false;

    // false 9 + '1'; // '91' 9 - '1'; // 8 null == undefined // true 0.1 + 0.2 == 0.3; // false . . .
  12. 21.

    JavaScript ͷ᠘̍ var hoge = ‘global’; function foo() { console.log(hoge);

    // undefined if (true) { var hoge = ‘local’; console.log(hoge); // local } } foo(); ม਺ͷר্͖͛໰୊
  13. 23.

    JavaScript ͷ᠘̍ const hoge = ‘global’; function foo() { console.log(hoge);

    // global if (true) { const hoge = ‘local’; console.log(hoge); // local } } foo(); 
  14. 24.

    JavaScript ͷ᠘̎ var Person = function(name){ this.name = name; };

    Person.prototype.sayName = function(){ console.log(this.name); // sottar var name = function() { console.log(this.name); // undefined }(); }; var sottar = new Person(‘sottar’) sottar.sayName(); UIJTͷࢀরมΘΔ໰୊
  15. 26.

    JavaScript ͷ᠘̎ var Person = function(name){ this.name = name; };

    Person.prototype.sayName = function(){ console.log(this.name); // sottar var hoge = () => { console.log(this.name); // sottar }; hoge(); }; var sottar = new Person(‘sottar’) sottar.sayName(); UIJTͷର৅͕มߋ͞Εͳ͍ 
  16. 27.

    JavaScript ͷ᠘̏ '' == false; // true '' === false;

    // false 9 + '1'; // '91' 9 - '1'; // 8 null == undefined // true 0.1 + 0.2 == 0.3; // false . . . ܕม׵Α͘Θ͔Βͳ͍໰୊
  17. 30.

    • ͲͪΒ΋ JavaScript ͷੈքʹܕΛ΋ͨΒ͢΋ͷ • FlowType ͸ Facebook੡ɺTypeScript ͸ Microsoft

    ੡ • React ͸ FlowType ΛಋೖɺAngular ͸ TypeScript Λಋೖ • Flowtype ͸ϓϩδΣΫτͷ్த͔Β΋ಋೖՄೳ FlowType or TypeScript
  18. 33.

    • ίʔϧόοΫ஍ࠈ => Promise, Async / Await • class ߏจ

    • Template literal, Spread operator, Destructuring assignment, import / export, Symbol ଞʹ΋͍Ζ͍Ζศརʹͳ͖͍ͬͯͯ·͢
  19. 34.

    class Λ࢖͏ͱ var Person = function(name){ this.name = name; };

    Person.prototype.sayName = function(){ console.log(this.name); var name = function() { console.log(this.name); }(); }; var sottar = new Person(‘sottar’) sottar.sayName();
  20. 35.

    class Λ࢖͏ͱ class Person { constructor(name){ This.name = name; }

    sayName = () => { console.log(this.name); var name = () => { console.log(this.name); }; name(); } } const sottar = new Person(‘sottar’) sottar.sayName();
  21. 39.

    • Single Page Application ͷུ • ୯ҰϖʔδͰߏ੒͞ΕΔWebΞϓϦέʔγϣϯ • ϖʔδભҠΛߦΘͣʹ JavaScript

    Ͱ DOM Λૢ࡞ͯ͠ϖʔδΛ੾Γସ͑Δ • Routing ͸ϑϩϯτଆͰߦͬͯɺదٓɺඞཁͳ৘ใΛAPIͰऔಘɾૹ৴͢Δ SPAͱ͸
  22. 49.

    SSR

  23. 50.

    • Server Side Rendering ͷུ • Client ଆ ͰϨϯμϦϯά͢Δ͜ͱΛ Client

    Side Rendering ͱݺͿ • ͦΕʹରͯ͠ Server ଆ Ͱ΋ϨϯμϦϯά͢Δ͜ͱΛ Server Side Rendering ͱݺͿ • ॳճͷΞΫηεͷ͚࣌ͩ Server ଆͰ Rendering Λߦ͏ SSRͱ͸
  24. 51.
  25. 53.

    BFF

  26. 56.

    • ैདྷͷ web ΞϓϦέʔγϣϯ • HTMLςϯϓϨʔτͰදࣔ • ߋ৽͸ form ܥ

    • SPAతͳ web ΞϓϦέʔγϣϯ • ϖʔδ͝ͱʹඞཁͳ৘ใΛ Ajax Ͱऔಘ͢Δ • ಈ͖΋ Ajax Λ࢖ͬͯΠϯλϥΫςΟϒʹ • 1ϖʔδදࣔ͢ΔͷʹԿճ΋APIΛ౤͛Δͷ͸ύϑΥʔϚϯε্Α͘ͳ͍ • υϝΠϯ୯ҐͰ͸ͳ͘ϖʔδ΍ඞཁͳ৘ใ୯ҐͰΤϯυϙΠϯτΛ࡞Γ͍ͨ BFF͕ඞཁͳཧ༝
  27. 58.

    BFFͱ͸ #SPXTFS %BUBCBTF "1* "1* %BUBCBTF #BDLFOET GPS 'SPOUFOET "1*

    ϖʔδΛߏங͢Δ σʔλͷૢ࡞ɾ؅ཧ 'SPOUFOE 4FSWFSTJEF
  28. 63.

    • The world’s most popular framework for APIs.ʢެࣜʣ • YAML

    or JSON Ͱ؅ཧՄೳ • REST API ͷઃܭ͔ΒυΩϡϝϯτԽɺςετɺσϓϩΠ·Ͱߦ ͏͜ͱ͕Ͱ͖Δ • APIఆٛ • Blueprint (ϞοΫ) • Codegen Swagger ͱ͸
  29. 64.

    • Swagger Editor • to design, define and document RESTful

    APIs in the Swagger Specification. • Swagger Codegen • to build server stubs and client SDKs directly from a Swagger defined RESTful API • Swagger UI • meant for consumption by JavaScript web projects that include module bundlers, such as Webpack, Browserify, and Rollup Swagger ͱ͸
  30. 65.

    • Swagger Editor • to design, define and document RESTful

    APIs in the Swagger Specification. • Swagger Codegen • to build server stubs and client SDKs directly from a Swagger defined RESTful API • Swagger UI • meant for consumption by JavaScript web projects that include module bundlers, such as Webpack, Browserify, and Rollup Swagger ͱ͸
  31. 75.