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

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

sota ohara
July 14, 2018
18k

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

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

sota ohara

July 14, 2018
Tweet

Transcript

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

    Web, JavaScript, React Sell, mercari NOW, CSTool @sottar_ sottar
  2. JavaScript ͷ᠘̍ var hoge = ‘global’; function foo() { console.log(hoge);

    // global? local? if (true) { var hoge = ‘local’; console.log(hoge); // global? local? } } foo();
  3. JavaScript ͷ᠘̍ var hoge = ‘global’; function foo() { console.log(hoge);

    // undefined if (true) { var hoge = ‘local’; console.log(hoge); // local } } foo();
  4. JavaScript ͷ᠘̍ var hoge = ‘global’; function foo() { var

    hoge; console.log(hoge); // -> undefined if (true) { var hoge = ‘local’; console.log(hoge); // -> local } } foo(); ࣮ࡍͷΤϯδϯͰ͸͜͏͍͏ղऍʹͳΔ ม਺ͷר্͖͛
  5. 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();
  6. 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();
  7. 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ͷࢦ͍ͯ͠Δ΋ͷ͕ҟͳΔ
  8. JavaScript ͷ᠘̏ '' == false; '' === false; 9 +

    '1'; 9 - '1'; null == undefined 0.1 + 0.2 == 0.3; . . .
  9. JavaScript ͷ᠘̏ '' == false; // true '' === false;

    // false 9 + '1'; // '91' 9 - '1'; // 8 null == undefined // true 0.1 + 0.2 == 0.3; // false . . .
  10. JavaScript ͷ᠘̍ var hoge = ‘global’; function foo() { console.log(hoge);

    // undefined if (true) { var hoge = ‘local’; console.log(hoge); // local } } foo(); ม਺ͷר্͖͛໰୊
  11. JavaScript ͷ᠘̍ const hoge = ‘global’; function foo() { console.log(hoge);

    // global if (true) { const hoge = ‘local’; console.log(hoge); // local } } foo(); 
  12. 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ͷࢀরมΘΔ໰୊
  13. 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ͷର৅͕มߋ͞Εͳ͍ 
  14. JavaScript ͷ᠘̏ '' == false; // true '' === false;

    // false 9 + '1'; // '91' 9 - '1'; // 8 null == undefined // true 0.1 + 0.2 == 0.3; // false . . . ܕม׵Α͘Θ͔Βͳ͍໰୊
  15. • ͲͪΒ΋ JavaScript ͷੈքʹܕΛ΋ͨΒ͢΋ͷ • FlowType ͸ Facebook੡ɺTypeScript ͸ Microsoft

    ੡ • React ͸ FlowType ΛಋೖɺAngular ͸ TypeScript Λಋೖ • Flowtype ͸ϓϩδΣΫτͷ్த͔Β΋ಋೖՄೳ FlowType or TypeScript
  16. • ίʔϧόοΫ஍ࠈ => Promise, Async / Await • class ߏจ

    • Template literal, Spread operator, Destructuring assignment, import / export, Symbol ଞʹ΋͍Ζ͍Ζศརʹͳ͖͍ͬͯͯ·͢
  17. 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();
  18. 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();
  19. • Single Page Application ͷུ • ୯ҰϖʔδͰߏ੒͞ΕΔWebΞϓϦέʔγϣϯ • ϖʔδભҠΛߦΘͣʹ JavaScript

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

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

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

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

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

    ϖʔδΛߏங͢Δ σʔλͷૢ࡞ɾ؅ཧ 'SPOUFOE 4FSWFSTJEF
  25. • The world’s most popular framework for APIs.ʢެࣜʣ • YAML

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