<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Tanakrit Saisillapee on Medium]]></title>
        <description><![CDATA[Stories by Tanakrit Saisillapee on Medium]]></description>
        <link>https://medium.com/@tanakritsai?source=rss-b80726280bf1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*irJYV9vNl2kAxL2o.jpg</url>
            <title>Stories by Tanakrit Saisillapee on Medium</title>
            <link>https://medium.com/@tanakritsai?source=rss-b80726280bf1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 19:17:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tanakritsai/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Filter out chrome extension request in network panel]]></title>
            <link>https://medium.com/@tanakritsai/filter-out-chrome-extension-request-in-network-panel-3b6cd61f2db1?source=rss-b80726280bf1------2</link>
            <guid isPermaLink="false">https://medium.com/p/3b6cd61f2db1</guid>
            <category><![CDATA[devtools]]></category>
            <category><![CDATA[chrome-extension]]></category>
            <category><![CDATA[chrome-dev-tools]]></category>
            <dc:creator><![CDATA[Tanakrit Saisillapee]]></dc:creator>
            <pubDate>Thu, 20 Dec 2018 10:07:38 GMT</pubDate>
            <atom:updated>2018-12-20T10:07:38.063Z</atom:updated>
            <content:encoded><![CDATA[<p>As far as I searched about this, the only way to filter it out is to enter a filter string -scheme:chrome-extension in the filter input on DevTools network panel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3LlDziNkLCvKyS90g4CCdw.png" /><figcaption>before filter chrome extension request</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uYDnTdzy16dv6J2N0C52Gg.png" /><figcaption>after filter chrome extension request</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b6cd61f2db1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Service มาจากไหน ใครเป็นคนสร้างมันมาให้เรา]]></title>
            <link>https://medium.com/zarewoft/service-%E0%B8%A1%E0%B8%B2%E0%B8%88%E0%B8%B2%E0%B8%81%E0%B9%84%E0%B8%AB%E0%B8%99-%E0%B9%83%E0%B8%84%E0%B8%A3%E0%B9%80%E0%B8%9B%E0%B9%87%E0%B8%99%E0%B8%84%E0%B8%99%E0%B8%AA%E0%B8%A3%E0%B9%89%E0%B8%B2%E0%B8%87%E0%B8%A1%E0%B8%B1%E0%B8%99%E0%B8%A1%E0%B8%B2%E0%B9%83%E0%B8%AB%E0%B9%89%E0%B9%80%E0%B8%A3%E0%B8%B2-523265136794?source=rss-b80726280bf1------2</link>
            <guid isPermaLink="false">https://medium.com/p/523265136794</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[dependency-injection]]></category>
            <category><![CDATA[engineering]]></category>
            <dc:creator><![CDATA[Tanakrit Saisillapee]]></dc:creator>
            <pubDate>Sat, 24 Nov 2018 18:08:53 GMT</pubDate>
            <atom:updated>2018-11-27T16:58:42.719Z</atom:updated>
            <content:encoded><![CDATA[<h3>Angular Service มาจากไหน ใครเป็นคนสร้างให้เรา</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*spd8qWUcvjC4YqbZ9D_NyA.png" /></figure><p>ใครที่เขียน Angular อยู่คงจะคุ้นชินกันกับการเรียกใช้เจ้า service ผ่านทาง constructor แบบนี้</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2e076e9f910085eac4c28dec40e7856d/href">https://medium.com/media/2e076e9f910085eac4c28dec40e7856d/href</a></iframe><p>สงสัยกันไหมครับว่า เอ๊ะ? เราแค่บอกว่า constructor มี parameter เป็น class นี้ แล้วเราก็ใช้มันได้เลย แล้วใครเป็นคนสร้าง object ของ class นี้แล้วส่งเข้ามาให้เราละ?</p><h3>ใครเป็นคนสร้าง?</h3><p>ในโลกของ Angular มีสิ่งนึงที่เรียกว่า Injector ครับ ซึ่งความหมายตามพจนานุกรมของ Injector คือ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1C30Wl9_WdyjwkQfLPcxZw.png" /><figcaption>นี่ก็ตรงไป</figcaption></figure><p>แปลว่าหัวฉีดหรือตัวฉีด สิ่งที่มันทำก็ตรงตามความหมายเลยครับ คือมันเป็นตัวฉีดของที่เราต้องการให้ ซึ่งการจะให้ Injector ส่งของให้เราได้มี 2 อย่างที่เราต้องทำครับ</p><ol><li>เราต้องบอก Injector ว่ามี service อะไรบ้างที่ Injector จะต้องรู้จัก เพื่อเวลาที่มีใครมาขอจะได้เอาของให้ได้ถูก</li><li>หมดแล้วครับ</li></ol><p>ถ้าใครที่เขียน Angular มาตั้งแต่ดึกดำบรรพ์ (ไม่นับ AngularJS นะครับ) จะคุ้นชินกับเจ้า option ของ NgModule ที่ชื่อ provider</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9308ce0f3426870dd58b7c3c35eaad27/href">https://medium.com/media/9308ce0f3426870dd58b7c3c35eaad27/href</a></iframe><p>เจ้า provider นี่ละครับที่เป็นตัวบอก injector ว่า “แกถือ service นี้อยู่นะ ถ้าใครมาขอก็ให้สร้างของจาก class นี้ให้เค้า” จากข้อความนี้จะเห็นว่าจริงๆแล้วตอนเราบอก Injector ว่าเค้าถืออะไรมันจะมี 2 ส่วนครับ ส่วนแรกคือ ชื่อ หรือ token ที่เอาไว้ใช้ระบุว่า dependency ชื่ออะไร กับวิธีการสร้างของที่ต้องส่งให้เวลามีคนมาขอ ถ้าเราเขียนการ register service ในรูปเต็มๆจะเป็น</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8615979fc96cccdca90dc4cb83c30cf9/href">https://medium.com/media/8615979fc96cccdca90dc4cb83c30cf9/href</a></iframe><p>ดูจากโค้ดจะเห็นว่าจริงๆเรา register อะไรลงไปก็ได้ ให้คืนค่าอะไรก็ได้ แต่ถ้าเรา register class มันก็จะเข้าใจว่า “อ้อ ชื่อนี้สร้างของจาก class นี้ให้เอง” ดูวิธีการ register อย่างอื่นนอกเหนือจาก class ได้จากบทความนี้หรือ document ของ Angular ได้เลยครับ</p><ul><li><a href="https://medium.com/devnote/%E0%B8%97%E0%B8%B3%E0%B8%84%E0%B8%A7%E0%B8%B2%E0%B8%A1%E0%B8%A3%E0%B8%B9%E0%B9%89%E0%B8%88%E0%B8%B1%E0%B8%81%E0%B8%81%E0%B8%B1%E0%B8%9A-dependency-injection-%E0%B9%83%E0%B8%99-angular-880cbf483239">ทำความรู้จักกับ Dependency Injection ใน Angular</a></li><li><a href="https://angular.io/guide/dependency-injection-providers">Angular</a></li></ul><p>เราใช้ท่าประกาศ provider แบบนี้กันมาเรื่อยๆจนถึง Angular เวอร์ชั่น 6 ก็มีคนบอกว่า “เฮ้นาย ท่านี้มันทำให้เขย่าต้นไม้ไม่ได้นะ (tree shaking คือการเช็คว่าของถูกใช้ป่าว ถ้าไม่ใช้ก็ไม่เอามา compile)” ที่มันใช้ไม่ได้เพราะว่า Angular ไม่สามารถเข้าไปคุ้ยหาโค้ดเราเพื่อดูว่าตัวไหนถูกใช้ไม่ถูกใช้ทั้งหมดได้ครับ เลยมีท่าใหม่ออกมา จากที่เราต้องเอา service ไป register ที่ module กลายเป็นให้เราบอกที่ service เลยว่า “ตัวฉันเองนี่ขึ้นตรงต่อใคร” อ๋า!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a14dcaaa457bc9f174a79978a81fd879/href">https://medium.com/media/a14dcaaa457bc9f174a79978a81fd879/href</a></iframe><p>ใน providedIn เราสามารถใส่ root เพื่อ register service ในระดับ application-wide (Injector ตัวสูงสุด จะพูดถึงในบทความถัดไปนะจ๊ะ) หรือใส่ class ของ module ก็ได้หากเราต้องการ register ในระดับ module นั้นๆ</p><blockquote>สองท่านี้ไม่ได้มีท่าไหนดีกว่าท่าไหนนะครับ ทั้งสองท่าสามารถใช้ได้แล้วแต่ตามสถานะการณ์</blockquote><p>ของที่ Injector ฉีดให้คนอื่นถ้ามันต้องถูกสร้างขึ้นมา อย่างเช่นถ้ามีคนบอกว่าขอ SomeService สิ่งที่ Injector ต้องส่งให้คือ instance ของ class นั้น เมื่อ Injector สร้างของที่ผูกกับ token ใดๆขึ้นมาแล้วของชิ้นนั้นจะไม่ถูกสร้างใหม่อีกเลยในอายุขัยของ Injector แปลว่าถ้ามีใครขอของจาก Injector ตัวเดียวกันจะได้ของชิ้นเดียวกัน</p><blockquote>ถ้ามีใครขอของจาก Injector ตัวเดียวกันจะได้ของชิ้นเดียวกัน</blockquote><h4><strong>แล้วของที่ Injector ถือถูกสร้างเมื่อไหร่ละ?</strong></h4><p>เมื่อมีใครเรียกขอของตัวนั้นครับ ถ้าขอไปแล้ว Injector คุ้ยดูในถังแล้วไม่เจอของก็จะสร้างขึ้นมาใหม่ให้ แต่ถ้าคุ้ยเจอว่ามีสร้างไว้แล้วก็จะส่งตัวนั้นกลับไปให้เลย</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FoGO1MPNUVbbk4%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FoGO1MPNUVbbk4%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia1.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExdGJscnFoMDNjOXhjMzRkamg0aGRjdjRnb3AwdHkwZzR4MGw5eHZtYyZlcD12MV9naWZzX2dpZklkJmN0PWc%2FoGO1MPNUVbbk4%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="328" frameborder="0" scrolling="no"><a href="https://medium.com/media/997f84ffadec4babb77e848559bbca07/href">https://medium.com/media/997f84ffadec4babb77e848559bbca07/href</a></iframe><h3>จบเลี้ยวจ้า</h3><p>ขอทิ้งท้ายบทความนี้ด้วยรูปสรุป Dependency Injection ใน Angular นะครับ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SFc0wTqEmT--6_w5lblGMA.png" /><figcaption>ใครทำรูปนี้ได้สวยกว่านี้ช่วยส่งมาทีครัช</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=523265136794" width="1" height="1" alt=""><hr><p><a href="https://medium.com/zarewoft/service-%E0%B8%A1%E0%B8%B2%E0%B8%88%E0%B8%B2%E0%B8%81%E0%B9%84%E0%B8%AB%E0%B8%99-%E0%B9%83%E0%B8%84%E0%B8%A3%E0%B9%80%E0%B8%9B%E0%B9%87%E0%B8%99%E0%B8%84%E0%B8%99%E0%B8%AA%E0%B8%A3%E0%B9%89%E0%B8%B2%E0%B8%87%E0%B8%A1%E0%B8%B1%E0%B8%99%E0%B8%A1%E0%B8%B2%E0%B9%83%E0%B8%AB%E0%B9%89%E0%B9%80%E0%B8%A3%E0%B8%B2-523265136794">Service มาจากไหน ใครเป็นคนสร้างมันมาให้เรา</a> was originally published in <a href="https://medium.com/zarewoft">Zarewoft</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[พัฒนา WordPress Theme บน Docker]]></title>
            <link>https://medium.com/zarewoft/%E0%B8%9E%E0%B8%B1%E0%B8%92%E0%B8%99%E0%B8%B2-wordpress-theme-%E0%B8%9A%E0%B8%99-docker-70e2f2db15a7?source=rss-b80726280bf1------2</link>
            <guid isPermaLink="false">https://medium.com/p/70e2f2db15a7</guid>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[wordpress]]></category>
            <category><![CDATA[docker-compose]]></category>
            <category><![CDATA[wordpress-themes]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Tanakrit Saisillapee]]></dc:creator>
            <pubDate>Sat, 27 Oct 2018 14:50:30 GMT</pubDate>
            <atom:updated>2018-11-24T18:32:20.691Z</atom:updated>
            <content:encoded><![CDATA[<p><em>คำเตือน : วิธีการนี้เหมาะสำหรับพัฒนาของให้กับ WordPress เท่านั้นนะครับ อย่างเช่นพัฒนา theme หรือ plugin วิธีนี้ไม่เหมาะกับการนำไปใช้รัน WordPress บน production จริงๆ</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pxBGIcKiuXfMQVXx_ZC71g.png" /></figure><p>บทความนี้ถูกเขียนขึ้นมาเนื่องมาจากว่าทางทีมได้รับโจทย์ให้พัฒนา <a href="https://codex.wordpress.org/Theme_Development">Theme WordPress</a> ให้กับทาง <a href="https://uxlabth.com/">UX Research Lab</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y8QdwTklnMegvQAiCl6wlg.png" /><figcaption>UX Research Lab logo</figcaption></figure><p>ซึ่งทางทีมเรามีประสบการณ์ในการพัฒนา Theme WordPress มานิดหน่อย แต่ไม่เคยพัฒนา Theme ขึ้นมาใหม่หมดเลยอย่างงานนี้ เราเลยเลือกที่จะขึ้น HTML และ CSS จากแบบที่ได้มาจากทาง Designer ก่อน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xqu0OO930qZnd1dT_yZMaQ.png" /><figcaption>Design ที่ได้มาจากทาง Designer</figcaption></figure><p>ทีนี้พอเราขึ้น HTML และ CSS เสร็จ เราก็อยากจะลองเอาไปใส่ใน WordPress ดู เพื่อที่จะใส่ code ให้แสดงผลตาม content จากตัว WordPress</p><p>ด้วยความที่ทุกคนในทีมไม่ค่อยชอบลง package ลงไปบนเครื่องตัวเองตรงๆ แล้วเราก็เห็นว่าถ้ารัน WordPress ขึ้นมาเป็น container มันเหมาะมาก</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DsYfikRM3nTyZOv51sVnRw.png" /><figcaption>ตัวอย่างไฟล์ docker-compose.yml ที่ใช้ใน project</figcaption></figure><p>เพราะเราสามารถใช้ <a href="https://docs.docker.com/compose/overview/">Docker Compose</a> ให้ช่วยรันทั้ง WordPress และ SQL Database ขึ้นมา พร้อมทั้งยังสามารถ config ต่างๆเก็บไว้ใน file compose ทุกครั้งที่เราสั่งรันมันขึ้นมาได้อีกด้วย อย่างในงานนี้ผมเป็นคนสร้างไฟล์ docker-compose.yml ใส่ไว้ใน project พอเพื่อนผมเอาโค้ดไปรันเค้าสามารถสั่ง docker-compose up ซึ่งมันจะรันทั้ง WordPress และ Database ขึ้นมาได้เลยโดยที่ไม่ต้องไปตั้งค่าอะไรอีก</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ukq1SCKO4Z-0i44URC7Rtw.png" /><figcaption>ตัวอย่างการ map file ใน project เข้าไปใน Wordpress บน container</figcaption></figure><p>เราสามารถ map file ที่อยู่ใน project เข้าไปใน WordPress ได้เลย แปลว่าเราไม่จำเป็นต้อง copy file ที่เรากำลังพัฒนาอยู่ไปใส่ใน folder wp-content/themes เพื่อลองทดสอบ theme เราดู มันเหมือนกับว่าไฟล์ที่อยู่ใน project เราคือไฟล์ที่อยู่ใน folder themes ใน wordpress เลย เวลาเราแก้ไฟล์ใน project แล้วเรา refresh หน้าเว็บ WordPress ของเรา มันก็จะเปลี่ยนตาม ถ้า project ใครที่ต้องมีการ build ก่อนก็สามารถ map folder ของไฟล์ที่ build ออกมาเข้าไปได้เหมือนกัน</p><p>ด้วยความที่ไม่ใช่งานที่ต้องพัฒนากันต่อยาวๆ (แต่ code อยู่บน git นะ) พอพัฒนาเสร็จก็ zip folder แล้วอัพเข้า WordPress ตัว production ซึ่งรันอยู่บน hosting เลย ไม่ได้เซ็ต CI/CD อะไรนะครับ เข้าไปรับชมเว็บไซด์ได้ที่ <a href="https://uxlabth.com/">https://uxlabth.com</a></p><p>จะเห็นว่าในขั้นตอนการพัฒนาเราไม่ต้องลง SQL Database ลงบนเครื่อง ไม่ต้องลง php หรือแม้แต่ web server เพื่อรัน WordPress เลย มันเป็นความฟินขั้นสุด</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fy8Mz1yj13s3kI%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fexcited-oprah-shouting-y8Mz1yj13s3kI&amp;image=https%3A%2F%2Fmedia1.giphy.com%2Fmedia%2Fy8Mz1yj13s3kI%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="326" frameborder="0" scrolling="no"><a href="https://medium.com/media/3fa8cd2316dc5c8d7d0f961f4458cac6/href">https://medium.com/media/3fa8cd2316dc5c8d7d0f961f4458cac6/href</a></iframe><p>ตัวอย่างไฟล์ docker-compose.yml ตามรูปด้านบนครับ สามารถเปลี่ยนข้อมูลได้ตามชอบนะครับ</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d135f6a96e588f841db071be5836aa44/href">https://medium.com/media/d135f6a96e588f841db071be5836aa44/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=70e2f2db15a7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/zarewoft/%E0%B8%9E%E0%B8%B1%E0%B8%92%E0%B8%99%E0%B8%B2-wordpress-theme-%E0%B8%9A%E0%B8%99-docker-70e2f2db15a7">พัฒนา WordPress Theme บน Docker</a> was originally published in <a href="https://medium.com/zarewoft">Zarewoft</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[วิธีทำให้ Amazfit Bip แสดงภาษาไทย(ลง font ไทย) และลงหน้าปัดเพิ่ม (Custom watch face) บน iOS ได้]]></title>
            <link>https://medium.com/@tanakritsai/%E0%B8%A7%E0%B8%B4%E0%B8%98%E0%B8%B5%E0%B8%97%E0%B8%B3%E0%B9%83%E0%B8%AB%E0%B9%89-amazfit-bip-%E0%B9%81%E0%B8%AA%E0%B8%94%E0%B8%87%E0%B8%A0%E0%B8%B2%E0%B8%A9%E0%B8%B2%E0%B9%84%E0%B8%97%E0%B8%A2-%E0%B8%A5%E0%B8%87-font-%E0%B9%84%E0%B8%97%E0%B8%A2-%E0%B9%81%E0%B8%A5%E0%B8%B0%E0%B8%A5%E0%B8%87%E0%B8%AB%E0%B8%99%E0%B9%89%E0%B8%B2%E0%B8%9B%E0%B8%B1%E0%B8%94%E0%B9%80%E0%B8%9E%E0%B8%B4%E0%B9%88%E0%B8%A1-custom-watch-face-%E0%B8%9A%E0%B8%99-ios-%E0%B9%84%E0%B8%94%E0%B9%89-4d7066e29d37?source=rss-b80726280bf1------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d7066e29d37</guid>
            <category><![CDATA[amazfit-bip]]></category>
            <category><![CDATA[smartwatch]]></category>
            <category><![CDATA[thai-font]]></category>
            <category><![CDATA[amaztools]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Tanakrit Saisillapee]]></dc:creator>
            <pubDate>Sun, 19 Aug 2018 16:40:07 GMT</pubDate>
            <atom:updated>2018-08-20T03:39:26.471Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wURksjNxbuZA2vBcJDETXA.jpeg" /><figcaption>ตัวอย่างภาษาไทยบน Amazfit Bip ว่ะฮ่ะฮ่า</figcaption></figure><p>วิธีทำง่ายมากครับ ทั้งสองอย่างมีขั้นตอนเริ่มต้นที่เหมือนกัน คือต้องลงแอพ AmazTools และ connect เข้ากับอุปกรณ์ของเราก่อน</p><p>ในบทความนี้จะแบ่งออกเป็น 3 ส่วนครับ</p><ol><li>ขั้นตอนเริ่มต้น</li><li>วิธีลงหน้าปัดเพิ่ม (Custom Watch Face)</li><li>วิธีทำให้แสดงภาษาไทยได้ (ลง Font ไทย)</li></ol><p><strong>คำเตือน</strong> <em>บทความนี้เต็มไปด้วยรูปครับ เตรียมอินเตอร์เน็ทให้พร้อมกันด้วยนะครับ</em></p><h3><strong>ขั้นตอนเริ่มต้น</strong></h3><ol><li>ลงแอพ Amaztools ลงในเครื่อง iOS ของเราจาก App Store ครับ</li></ol><p><a href="https://itunes.apple.com/us/app/amaztools/id1386033880?mt=8">‎AmazTools on the App Store</a></p><p>2. เปิดเข้า app Amaztools ครั้งแรกจะเจอกล่องต้อนรับขึ้นมา ให้กดปุ่ม Setup</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hxC3vVoi2P4s0kvw8t7piQ.jpeg" /></figure><p>3. แล้วให้กดปุ่ม Search Device เพื่อค้นหาอุปกรณ์ของเรา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UGkzM5wux5E5c-uVRM_IQw.jpeg" /></figure><p>4. เสร็จแล้วเราจะเห็นรายชื่ออุปกรณ์ของเรา แล้วให้เราเลือกอุปกรณ์ที่เราต้องการเชื่อมต่อครับ ของผมคือ Amazfit Bip</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KUtQ0Np9t_NkBbgmfuMcCQ.jpeg" /></figure><p>5. แล้วกด Continue</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PHLx8FQJFFSLFUhuQffufQ.jpeg" /></figure><p>6. ถ้าเชื่อมต่อสำเร็จเราจะเจอหน้าแบบนี้ครับ แล้วกด Close ได้เลย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AxpJhElvhWf2D5UiuVtQ5Q.jpeg" /></figure><h3>วิธีลงหน้าปัดเพิ่ม (Custom Watch Face)</h3><ol><li>เลือกเมนู Browse แล้วเลือกหน้าตาหน้าฬิกาที่ต้องการ อย่างของผมผมเลือก Watchface 1881</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CXR6rb9ynE-U8M2JpqMJsA.png" /></figure><p>2. พอเข้ามาในหน้ารายละเอียดให้กด Download</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yo6TGOSp1HUV8hywP1-i6A.png" /></figure><p>3. แล้วรอให้ Download เสร็จ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sTMSxJ1GVJbBI8JfW078oA.png" /></figure><p>4. เลือกไปที่เมนู Downloads แล้วเลือกแบบหน้าปัดที่เราต้องการติดตั้งลงในนาฬิกา อย่างของผมผมเลือก Watchface 1881</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E-V1ldMil5OAQhPU0e7ZAw.png" /></figure><p>5. จะมี menu ขึ้นมา เลือก Install ครับ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vtzT_ec34gYYJgH4AJLWrg.png" /></figure><p>6. เราจะเจอหน้าตัวอย่างหน้าปัด ให้กดปุ่ม install อีกครั้ง ขั้นตอนนี้ให้นาฬิกาอยู่ใกล้กับมือถือนะครับ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uScypywiCwMnB718iSZh-g.png" /></figure><p>7. รอจนกว่าจะติดตั้งเสร็จสิ้นครับ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bM5Nkk0TVMq3uKqjxY1aKg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_g_A3cIviNkeb1wE1HYNjg.jpeg" /><figcaption>นาฬิกาจะแสดงข้อความเสร็จสิ้น</figcaption></figure><p>8. เรียบร้อยแล้วครับ 🎉</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t-mOLC0d58WGZOoYUU7S6Q.jpeg" /></figure><h3>วิธีทำให้แสดงภาษาไทยได้ (ลง Font ไทย)</h3><ol><li>เปิด link สำหรับโหลด font ภาษาไทยขึ้นมาครับ</li></ol><p><a href="https://github.com/ionoze/AmazfitBip_ThaiFont/blob/master/Mili_chaohu_uni.ft?raw=true">https://github.com/ionoze/AmazfitBip_ThaiFont/blob/master/Mili_chaohu_uni.ft?raw=true</a></p><p>2. เมื่อเปิด link ขึ้นมาจะเจอข้อมูลของไฟล์และมีตัวเลือก 2 ตัว ให้เลือก Open in “AmazfitTools”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fcPcXPxQk6PW63JNSdeD1w.jpeg" /></figure><p>3. แอพ AmazTools จะถูกเปิดขึ้นมา พร้อมกับรายละเอียดในการลง font ให้กด Install เลยครับ ขั้นตอนนี้ให้นาฬิกาอยู่ใกล้กับมือถือนะครับ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qHxddcpc8eHVprIGYcU-qg.jpeg" /></figure><p>4. รอจนกว่าจะติดตั้งเสร็จครับ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MY5DB3sEAUz3b6zF55JYSg.png" /></figure><blockquote>หากเจอ error ขึ้นข้อความแบบนี้ ให้เปิดแอพ Mi Fit ขึ้นมารอให้ Sync ข้อมูลกันเสร็จแล้วกลับมาที่แอพ AmazTools แล้ว Install ใหม่อีกครั้ง</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ooqin9xcZytVKx3Pr1qwZA.jpeg" /></figure><p>5. เสร็จแล้วเครื่องเราก็จะสามารถแสดงภาษาไทยได้แล้วครับ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wURksjNxbuZA2vBcJDETXA.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d7066e29d37" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Polymer 3.0 Preview; npm, ES6 Module]]></title>
            <link>https://medium.com/zarewoft/polymer-3-0-preview-npm-es6-module-8bf93fad7a78?source=rss-b80726280bf1------2</link>
            <guid isPermaLink="false">https://medium.com/p/8bf93fad7a78</guid>
            <category><![CDATA[npm]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[web-components]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[polymer]]></category>
            <dc:creator><![CDATA[Tanakrit Saisillapee]]></dc:creator>
            <pubDate>Tue, 22 Aug 2017 11:35:42 GMT</pubDate>
            <atom:updated>2018-11-24T18:33:01.134Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HfjHrUE-nHNwuLN_MXa8pA.png" /><figcaption>Polymer 3.0</figcaption></figure><p>ในงาน Polymer Summit 2017 ปีนี้มีโชว์ Polymer 3.0 ให้ดูด้วยว่าจะมีอะไรเปลี่ยนแปลงบ้างครับ</p><h3><strong>Bower → npm</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iTELuBJy8O6pi52FluyAlg.png" /><figcaption>Yarn + npm = npm with flat dependency tree</figcaption></figure><p>อย่างแรกเลย เปลี่ยนจากเอา Element ต่างๆไว้บน Bower มาอยู่บน npm แทน</p><p>ต้องเท้าความกันก่อนเลยว่าสาเหตุที่ของ Polymer และ element ต่างๆไปอยู่บน Bower ในตอนแรกเพราะ Bower รองรับ flat dependency แต่ตัว Bower เองเนี่ยไม่ได้รับการพัฒนาต่อแล้วและก็ไม่ค่อยมีคนใช้แล้วด้วย</p><p>ทางทีม Polymer เลยตัดสินใจย้ายไป npm เลยดีกว่าเพราะน่าจะทำให้คนเข้าถึง Web Component ได้เยอะขึ้นด้วย community ขนาดใหญ่ของ npm แต่ทางทีม Polymer เองก็ต้องหาทางทำให้ dependency ที่ติดมากับ package นั้นอยู่ในรูปแบบของ flat dependency ด้วย ซึ่งตอนนี้ก็มีท่าของ yarn เองที่สามารถทำ flat dependency ได้</p><h3><strong>HTML Import → ES6 Module</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6r_F5f6Fnh_ZXhNdZBWEWg.png" /><figcaption>Es Module for loading custom component</figcaption></figure><p>Polymer เองใช้วิธีการโหลด dependency ตัวอื่นด้วย HTML Import ซึ่งตัว HTML Import เองเนี่ยมีฟีเจอร์เจ๋งๆตามนี้เลย</p><ul><li>Web-native loading mechanism. คือไม่ต้องใช้เครื่องมืออื่นช่วยในการโหลดโค้ดเลย</li><li>Transitive loading of dependencies with ordered evaluation. คือการโหลด dependency ตามลำดับครับ เช่น ถ้าใน A โหลด B และใน B โหลด C แปลว่า C และ B จะถูกโหลดก่อน A</li><li>Deduplication of dependencies by URL. ป้องกันการโหลด dependency ซ้ำครัช ถ้ามีการโหลด dependency ตัวเดิมหลายๆครังมันจะถูกโหลดแค่ครั้งเดียว</li><li>Native HTML parsing. ตามชื่อเลยครับ parse HTML แบบ native ด้วย browser เอง</li></ul><p>แต่ตัว HTML Import เองนี่ไม่ได้รับการตอบรับจากทางเหล่าชุมชน web standard และเหล่าเบราเซอร์ ถ้าจะรอให้ได้รับการยอมรับจากทุกคนนี่คงรออีกนานหลายปีเลยครับ</p><p>ในทางกลับกันตัว ES6 Module นี่ได้รับการตอบรับจากทุกเบราเซอร์ และทุก Browser ก็รองรับ ES6 Module ซึ่งตัว ES6 Module เองนี่มีฟีเจอร์คล้ายกับ HTML Import จะขาดก็แต่แค่ฟีเจอร์ Native HTML parsing</p><p>ทางทีม Polymer เลยเห็นว่าคงเป็นการดีกว่าที่จะย้ายไปใช้ ES6 Module ในการช่วยโหลด Element ข้อดีอีกอย่างคือจะทำให้สามารถใช้งานกับ JS Library หรือ framework ตัวอื่นได้ง่ายขึ้นด้วย</p><h3><strong>แล้วจะมาเมื่อไหร่</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ytVj8e47ppiZ8K7Km3OYUA.png" /><figcaption>กำหนดการอย่างคร่าวๆของ Polymer 3.0</figcaption></figure><p>ตอนนี้สามารถลองใช้ 3.0 Preview ได้ที่ branch 3.0-preview ของ repo Polymer เลยครับ แต่ยังห่างไกลจากการที่จะเอาไปใช้บน production จริงนะครับ มีอีกหลายอย่างที่ทีม Polymer ต้องทำ ซึ่งอาจจะมีการเปลี่ยนแปลงอีกเรื่อยๆ</p><p>สำหรับใครที่ใช้ 2.0 อยู่ไม่ต้องห่วงนะครับ ทางทีม Polymer การันตีว่าจะสามารถย้ายไป 3.0 ได้อย่างง่ายดาย</p><p>อ่าน Blog ต้นฉบับได้ที่นี่ครับ <br><a href="https://www.polymer-project.org/blog/2017-08-22-npm-modules">https://www.polymer-project.org/blog/2017-08-22-npm-modules</a></p><p><a href="https://www.polymer-project.org/blog/2017-08-22-npm-modules">Polymer 3.0 preview: npm and ES6 Modules - Polymer Project</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8bf93fad7a78" width="1" height="1" alt=""><hr><p><a href="https://medium.com/zarewoft/polymer-3-0-preview-npm-es6-module-8bf93fad7a78">Polymer 3.0 Preview; npm, ES6 Module</a> was originally published in <a href="https://medium.com/zarewoft">Zarewoft</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“iTunes” could not be verified.(311)]]></title>
            <link>https://medium.com/@tanakritsai/itunes-could-not-be-verified-311-23a9a6795ab8?source=rss-b80726280bf1------2</link>
            <guid isPermaLink="false">https://medium.com/p/23a9a6795ab8</guid>
            <category><![CDATA[macos]]></category>
            <category><![CDATA[macos-sierra]]></category>
            <category><![CDATA[mac-os-x]]></category>
            <category><![CDATA[mac]]></category>
            <category><![CDATA[itunes]]></category>
            <dc:creator><![CDATA[Tanakrit Saisillapee]]></dc:creator>
            <pubDate>Sat, 22 Jul 2017 17:58:33 GMT</pubDate>
            <atom:updated>2017-07-22T17:58:33.527Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*6i9sDMz2UgkT_92rYhTlWw.png" /><figcaption>iTunes 12.6.2</figcaption></figure><p>If you found this message when you try to update iTunes or Mac OS with iTunes, just download and install new version of iTunes manually. You can download iTunes from this link.</p><p><a href="https://www.apple.com/itunes/download/">iTunes - Download iTunes Now</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=23a9a6795ab8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[เริ่มต้นใช้ Polymer 2.0 สร้าง Web Component]]></title>
            <link>https://medium.com/zarewoft/%E0%B9%80%E0%B8%A3%E0%B8%B4%E0%B9%88%E0%B8%A1%E0%B8%95%E0%B9%89%E0%B8%99%E0%B9%83%E0%B8%8A%E0%B9%89-polymer-2-0-%E0%B8%AA%E0%B8%A3%E0%B9%89%E0%B8%B2%E0%B8%87-web-component-bf1b79930188?source=rss-b80726280bf1------2</link>
            <guid isPermaLink="false">https://medium.com/p/bf1b79930188</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[polymer]]></category>
            <category><![CDATA[web-components]]></category>
            <dc:creator><![CDATA[Tanakrit Saisillapee]]></dc:creator>
            <pubDate>Wed, 26 Apr 2017 14:29:13 GMT</pubDate>
            <atom:updated>2018-11-24T18:33:08.671Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YrOEV-GWiqNS6iqW1MOeQQ.png" /><figcaption>Polymer 2.0</figcaption></figure><h3>Polymer คืออะไร</h3><p>หากใครที่ได้อ่าน blog ของผมก่อนหน้านี้ที่อธิบายเรื่องของ Web Component ไว้อาจจะสงสัยว่าในเมื่อเราสามารถสร้าง Web Component โดยที่ไม่ต้องใช้ library อะไรช่วย แล้วทำไมเราถึงต้องใช้ Polymer? (หากใครยังไม่ได้อ่านเรื่องของ Web Component กลับไปอ่านได้ที่นี่นะครับ)</p><p><a href="https://medium.com/@zixsma/web-components-b20301f1cd33">Web Components มาตรฐานใหม่ของ Web</a></p><p>Polymer คือ library ที่มาช่วยลดความซับซ้อนในการสร้าง web component และเรายังได้ความสามารถบางอย่างโดยที่เราไม่ต้องเขียนโค้ดเองเช่น Data Binding, DOM templating, Property Declaration และอีกมากมาย เดี๋ยวเรามาดูกันนะครับว่าการสร้าง web component ด้วย Polymer เป็นยังไง</p><h3>สร้าง Web Component ด้วย Polymer</h3><p>เพื่อความง่ายในการทำความเข้าใจเราจะใช้ Plunker รันโค้ดให้เรานะครับ แนะนำให้ Plunker ของแต่ละเรื่องขึ้นมาและอ่านคำอธิบายตาม แล้วลองแก้ค่า Plunker เพื่อความเข้าใจมากขึ้นนะครับ</p><h4>Register element</h4><p><a href="http://plnkr.co/edit/PaCt2M?p=options">Plunker</a></p><p>ขั้นตอนการสร้าง web component ด้วย polymer เริ่มต้นด้วย สร้างไฟล์ใหม่ขึ้นมาสำหรับ component ใหม่ของเราซึ่งในตอนนี้คือ custom-element.html แล้ว import polymer library เข้ามา</p><pre>&lt;link rel=&quot;import&quot; href=&quot;https://polygit.org/polymer+2.0.0-rc.2/components/polymer/polymer-element.html&quot;&gt;</pre><p>ที่เราต้อง import polymer เข้ามาเพราะเราจะต้องสร้าง class ที่ extend Polymer.Element</p><pre>&lt;script&gt;<br>   class CustomElement extends Polymer.Element {     <br>      static get is() { return &quot;custom-element&quot;; }     <br>   }</pre><pre>   customElements.define(CustomElement.is, CustomElement); <br>&lt;/script&gt;</pre><p>Polymer มี pattern ในการระบุชื่อ tag ของ custom element ด้วยการประกาศ property is เป็นแบบ static และ read only เมื่อประกาศ class เสร็จแล้วก็ register custom element ด้วย customElements.define()<br>แค่นี้เราก็ได้ custom element ที่สร้างด้วย Polymer แล้วครับ</p><h4>Add shadow DOM</h4><p><a href="http://plnkr.co/edit/bVyU2T?p=preview">Plunker</a></p><p>ถ้า custom element ของเรามี ui เราสามารถใช้ Polymer’s DOM templating ช่วยเราสร้าง template ภายใต้ shadow DOM ได้ วิธีการคือใส่ tag &lt;dom-module&gt; ครอบ &lt;script&gt; และระบุ property id ของ &lt;dom-module&gt; เป็นชื่อเดียวกับชื่อ tag ของ custom element</p><pre>&lt;dom-module id=&quot;dom-element&quot;&gt;</pre><pre>   &lt;style&gt;<br>      p { color: red; }<br>   &lt;/style&gt;  </pre><pre>   &lt;template&gt;     <br>      &lt;p&gt;I&#39;m a DOM element. This is my shadow DOM!&lt;/p&gt;   <br>   &lt;/template&gt;<br>  <br>   &lt;script&gt;     <br>      class DomElement extends Polymer.Element {       <br>         static get is() { return &quot;dom-element&quot;; }     <br>      }     <br>      customElements.define(DomElement.is, DomElement);   <br>   &lt;/script&gt;  <br>&lt;/dom-module&gt;</pre><p>เสร็จแล้วเพิ่ม tag &lt;template&gt; เข้าไป dom ของ custom element เราจะอยู่ภายใต้ tag &lt;template&gt;</p><p>และเราสามารถเขียน style ได้เพียงแค่ใส่ tag &lt;style&gt; เข้าไปภายใต้ &lt;dom-module&gt; style ที่ถูกประกาศภายใต้ shadow DOM จะมีผลเฉพาะกับ dom ที่ถูกประกาศภายใต้ shadow DOM เดียวกันเท่านั้น</p><h4>Data binding</h4><p><a href="http://plnkr.co/edit/zQ1wDurBLE4SJIkLFh2P?p=preview">Plunker</a></p><p>เพื่อความสะดวกสบาย Polymer ได้ใส่ data binding มาให้เราด้วยครับ ซึ่งมี 2 แบบคือ</p><pre>This is &lt;b&gt;[[owner]]&lt;/b&gt;&#39;s name-tag element.<br>&lt;iron-input bind-value=&quot;{{owner}}&quot;&gt;<br>   &lt;input is=&quot;iron-input&quot; placeholder=&quot;Your name here...&quot;&gt;<br>&lt;/iron-input&gt;</pre><ol><li>One-way data binding วิธีนี้ค่าของตัวแปรจะเปลี่ยนได้จากใน code อย่างเดียว วิธีการใช้คือใส่ [[]] ครอบตัวแปร</li><li>Two-way data binding วิธีนี้ค่าของตัวแปรสามารถเปลี่ยนได้จากใน code และจากทาง ui วิธีใช้คือใส่ {{}} ครอบตัวแปร</li></ol><p>จากในตัวอย่างตัวแปร owner จะเปลี่ยนค่าตาม input เพราะ binding แบบ two-way ไว้ หากเราเปลี่ยนจาก {{}} เป็น [[]] ตัวแปร owner จะไม่เปลี่ยนค่าตาม input</p><p>ลองเล่นใน plunker กันดูนะครับ ที่ &lt;input&gt; ต้องมีตัว &lt;iron-input&gt; ครอบเพราะ &lt;input&gt; ไม่มี data binding ให้เราใช้ครับ เราจะมาลงรายละเอียดเรื่องนี้กันอีกทีในบทความของ data binding โดยเฉพาะ</p><h4>Property declaration</h4><p><a href="http://plnkr.co/edit/SEm7jd?p=preview">Plunker</a></p><p>เราสามารถประกาศ property ของ custom element ของเราได้ง่ายๆด้วย syntax</p><pre>static get properties() {         <br>   return {           <br>      owner: {             <br>         type: String,             <br>         value: &#39;Daniel&#39;           <br>      }         <br>   };       <br>}</pre><p>ตอนนี้เวลาใครเอา custom element ของเราไปใช้ เค้าสามารถให้ค่า property owner ได้</p><pre>&lt;configurable-name-tag owner=&quot;Scott&quot;&gt;&lt;/configurable-name-tag&gt;</pre><p>ไม่ยากเลยใช่ไหมครับการใช้ Polymer สร้าง web component เดี๋ยวบทความต่อไปผมจะเขียนถึง Polymer CLI เพื่อสร้าง project บนเครื่องของเรากันนะครับ</p><p>Ref: <a href="https://www.polymer-project.org/2.0/start/quick-tour">https://www.polymer-project.org/2.0/start/quick-tour</a></p><h3>ช่วงโฆษณาครับ</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*xJXlK9aISKtkPCl3u5SSMQ.png" /><figcaption>สัญลักษณ์ Web Component (ซ้าย) และ สัญลักษณ์ Polymer (ขวา)</figcaption></figure><p>ใครสนใจ Web Component สามารถ Join Facebook group <a href="https://www.facebook.com/groups/282466182190660/">Polymer and Web Component Developer Thailand</a> ใน Facebook เพื่อมาคุยกันได้นะครับ</p><p>ปล. Web Component สามารถเอาไปใช้กับ framework อื่นๆได้นะครับ</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bf1b79930188" width="1" height="1" alt=""><hr><p><a href="https://medium.com/zarewoft/%E0%B9%80%E0%B8%A3%E0%B8%B4%E0%B9%88%E0%B8%A1%E0%B8%95%E0%B9%89%E0%B8%99%E0%B9%83%E0%B8%8A%E0%B9%89-polymer-2-0-%E0%B8%AA%E0%B8%A3%E0%B9%89%E0%B8%B2%E0%B8%87-web-component-bf1b79930188">เริ่มต้นใช้ Polymer 2.0 สร้าง Web Component</a> was originally published in <a href="https://medium.com/zarewoft">Zarewoft</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[สร้าง Web Component]]></title>
            <link>https://medium.com/zarewoft/%E0%B8%AA%E0%B8%A3%E0%B9%89%E0%B8%B2%E0%B8%87-web-component-a2de58c56fb8?source=rss-b80726280bf1------2</link>
            <guid isPermaLink="false">https://medium.com/p/a2de58c56fb8</guid>
            <category><![CDATA[polymer]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[web-components]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[engineering]]></category>
            <dc:creator><![CDATA[Tanakrit Saisillapee]]></dc:creator>
            <pubDate>Mon, 03 Apr 2017 08:36:01 GMT</pubDate>
            <atom:updated>2018-08-15T10:56:32.638Z</atom:updated>
            <content:encoded><![CDATA[<p>บทความนี้เป็นการอธิบายการสร้าง web component เบื้องต้นครับ ดังนั้นจะไม่ได้ลงรายละเอียดลึก</p><p>สำหรับใครที่ยังไม่รู้ว่า Web Component คืออะไร ลองอ่านบทความนี้ก่อนนะครับ</p><p><a href="https://medium.com/@zixsma/web-components-b20301f1cd33">Web Components มาตรฐานใหม่ของ Web</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/1*5q4HfZZYtdTF0YqhqBpWQQ.png" /></figure><p>ทั้งบทความนี้จะเป็นการอธิบายด้วย syntax ของ Web Components specification เวอร์ชั่น v1 นะครับ</p><h3>วิธีการสร้าง HTML element ใหม่</h3><p>เราใช้ JavaScript ในการประกาศ HTML Element และ tag ใหม่ขึ้นมาซึ่งจะอยู่ใน global scope เลยครับ</p><p>ประกาศได้โดยการเรียก customElements.define() พร้อมกับ tag name ที่คุณต้องการสร้างและ Javascript class ที่ extends HTMLElement</p><p>ตัวอย่างการสร้าง drawer panel &lt;app-drawer&gt;</p><pre>class AppDrawer extends HTMLElement {...}<br>window.customElements.define(&#39;app-drawer&#39;, AppDrawer);</pre><p>เมื่อเราต้องการใช้ tag ใหม่ที่เราสร้างขึ้นมาก็แค่เรียก</p><pre>&lt;app-drawer&gt;&lt;/app-drawer&gt;</pre><p>การใช้ custom element ก็ไม่ต่างอะไรกับการใช้ &lt;div&gt; หรือ element อื่นๆเลยครับ ตัว custom element นี้สามารถทำงานได้เหมือน default element ได้ทุกอย่างเลย ทั้งการประกาศใช้บนเว็บเพจ การสร้างขึ้นจากคำสั่งของ JavaScript การผูก event listener และอื่นๆ</p><pre>&lt;script&gt;<br>// Create with javascript<br>var newDrawer = document.createElement(‘app-drawer’);<br>// Add it to the page<br>document.body.appendChild(newDrawer);<br>// Attach event listeners<br>document.querySelector(‘app-drawer’).addEventListener(‘open’, function() {...});<br>&lt;/script&gt;</pre><h3>การสร้างและใช้ shadow root</h3><p>Shadow DOM คือฟีเจอร์ใหม่ของ DOM ที่มาช่วยในการสร้าง component ครับ เรามองได้ว่า shadow DOM นี่เป็นการแยกส่วนของ DOM ใน component เรากับ DOM อื่นๆ ออกจากกันครับ</p><p>Shadow root คือส่วนของ document ที่ติดอยู่กับ “host” element <br>การเอา shadow root ไปติดกับ “host” element ทำให้เราได้ shadow DOM ครับ<br>การเอา shadowRoot ไปติดกับ host หรือการสร้าง shadow DOM นี้ทำได้โดยเรียก element.attachShadow()</p><pre>const header = document.createElement(&#39;header&#39;);<br>const shadowRoot = header.attachShadow({mode: &#39;open&#39;});<br>shadowRoot.innerHTML = &#39;&lt;h1&gt;Hello Shadow DOM&lt;/h1&gt;&#39;; // Could also use appendChild().<br>// header.shadowRoot === shadowRoot<br>// shadowRoot.host === header</pre><p>หากต้องการศึกษาเพิ่มเติมเกี่ยวกับ shadow DOM แนะนำให้อ่านที่บทความนี้ครับ จะช่วยให้เข้าใจ shadow DOM มากยิ่งขึ้น ด้วยการเปรียบเทียบตัวอย่างการใช้งาน shadow DOM v0 และ v1 เปรียบเทียบกัน <a href="http://hayato.io/2016/shadowdomv1/">Hayato Ito’s comparison of v0 and v1 of the shadow DOM specification</a>.</p><h3>Libraries สำหรับสร้าง web components</h3><p>ปัจจุบันมี library ที่ช่วยสร้าง web component หลายตัวเลยครับ นี่คือตัวอย่างของ library ที่ช่วยสร้าง web component</p><ul><li><a href="https://bosonic.github.io/">Bosonic</a> เป็นชุดของ components ที่ออกแบบมาตอบสนองความต้องการใช้ของ developer ครับ</li><li><a href="https://www.polymer-project.org/">Polymer</a> เป็น library ที่มีฟีเจอร์ช่วยสร้าง custom elements มากมายเลยครับ</li><li><a href="https://github.com/skatejs/skatejs">SkateJS</a> เป็น JavaScript library สำหรับช่วยสร้าง web components ตัว library เองมีขนาดเล็กครับ</li><li><a href="https://x-tag.github.io/">X-Tag</a> เป็น open source JavaScript library ที่มี interface สำหรับช่วยสร้าง component ครับ</li></ul><p>Keep calm and <a href="https://www.webcomponents.org/">#UseThePlatform</a><br>บทความนี้ถูกแปลมาจาก <a href="https://www.webcomponents.org/introduction">https://www.webcomponents.org/introduction</a></p><h3>ช่วงโฆษณาครับ</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*xJXlK9aISKtkPCl3u5SSMQ.png" /><figcaption>สัญลักษณ์ Web Component (ซ้าย) และ สัญลักษณ์ Polymer (ขวา)</figcaption></figure><p>ใครสนใจ Web Component สามารถ Join Facebook group <a href="https://www.facebook.com/groups/282466182190660/">Polymer and Web Component Developer Thailand</a> ใน Facebook เพื่อมาคุยกันได้นะครับ</p><p>ปล. Web Component สามารถเอาไปใช้กับทุกเฟรมเวิคได้หมดนะ Angular, React, Vue ฯลฯ ใช้ร่วมกันได้หมดเลย</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2de58c56fb8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/zarewoft/%E0%B8%AA%E0%B8%A3%E0%B9%89%E0%B8%B2%E0%B8%87-web-component-a2de58c56fb8">สร้าง Web Component</a> was originally published in <a href="https://medium.com/zarewoft">Zarewoft</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Web Components มาตรฐานใหม่ของ Web]]></title>
            <link>https://medium.com/zarewoft/web-components-b20301f1cd33?source=rss-b80726280bf1------2</link>
            <guid isPermaLink="false">https://medium.com/p/b20301f1cd33</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[web-components]]></category>
            <category><![CDATA[polymer]]></category>
            <category><![CDATA[engineering]]></category>
            <dc:creator><![CDATA[Tanakrit Saisillapee]]></dc:creator>
            <pubDate>Mon, 03 Apr 2017 06:22:31 GMT</pubDate>
            <atom:updated>2018-11-24T18:33:29.200Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fie55JSnlE1PiNpETdGSQA.png" /><figcaption>สัญลักษณ์ Web Component</figcaption></figure><h3>Web Components คืออะไร</h3><p>Web Components คือ ชุดคำสั่ง APIs ของ web platform ที่ทำให้เราสามารถสร้างและใช้ HTML tag ที่ถูกปรับแต่งขึ้นมาในเว็บเพจและเว็บแอพของเราได้ ซึ่งตัว HTML tag ที่เราสร้างขึ้นมาใหม่นี่จะถูกเรียกว่า custom component, custom element หรือ widget ซึ่งสามารถใช้ได้กับ browser สมัยใหม่ และสามารถนำไปใช้ร่วมกับ Javascript library ตัวอื่นหรือ framework อื่นๆที่ทำงานร่วมกับ HTML ได้</p><p>Web components เป็นมาตรฐานใหม่ที่ถูกเพิ่มขึ้นจากมาตรฐานเดิมของ web ตอนนี้ฟีเจอร์ที่รองรับการใช้งาน web components กำลังถูกเพิ่มเข้าไปในมาตรฐานของ HTML และ DOM เรื่อยๆ ในอนาคตอันใกล้เราจะสามารถสร้างและใช้ custom component ได้บนทุก browser</p><h3>Specifications</h3><p>Web Components ทำงานอยู่บน 4 สเปคหลัก</p><p><strong>Custom Elements<br></strong><a href="https://w3c.github.io/webcomponents/spec/custom/">Custom Elements </a><a href="https://w3c.github.io/webcomponents/spec/imports/">specification</a> เป็นพื้นฐานของการออกแบบและการใช้ DOM elements ประเภทใหม่ๆ</p><p><strong>Shadow DOM<br></strong><a href="https://w3c.github.io/webcomponents/spec/shadow/">shadow DOM </a><a href="https://w3c.github.io/webcomponents/spec/imports/">specification</a> ระบุวิธีการใช้ style และ markup ที่ถูกหุ้มอยู่ใน web components</p><p><strong>HTML imports<br></strong><a href="https://w3c.github.io/webcomponents/spec/imports/">HTML imports specification</a> ระบุการนำเข้าและใช้ซ้ำของ HTML documents ใน HTML documents อื่นๆ</p><p><strong>HTML Template<br></strong><a href="https://html.spec.whatwg.org/multipage/scripting.html#the-template-element/">HTML template element specification</a> ระบุการประกาศบางส่วนของ markup ที่ไม่ได้ถูกใช้ตอนหน้าเพจถูกโหลดแต่สามารถถูกสร้างขึ้นมาทีหลังตอนที่หน้าเว็บทำงานแล้ว</p><h3>Web component ใช้ยังไง?</h3><p>สามารถหา HTML elements ที่คนอื่นทำไว้แล้วและสามารถนำมาใช้ได้จาก <a href="https://www.webcomponents.org/">https://www.webcomponents.org</a> ครับ</p><p>การนำเข้าและการใช้ custom element นั้นง่ายมาก ยกตัวอย่างการใช้ <a href="https://beta.webcomponents.org/element/notwaldorf/emoji-rain">Emoji Rain element</a></p><pre>&lt;link rel=&quot;import&quot; href=&quot;../emoji-rain/emoji-rain.html&quot;&gt;<br>...<br>&lt;emoji-rain active&gt;&lt;/emoji-rain&gt;</pre><p>วิธีการติดตั้ง custom elements นั้นมีหลากหลายวิธีมาก ให้ลองดูใน README ของ element ที่คุณจะใช้ครับในนั้นจะมีวิธีการติดตั้งอยู่</p><p>Elements ส่วนใหญ่จะสามารถติดตั้งได้ผ่าน Bower ครับ เนื่องจาก Bower รองรับการช่วยติดตั้ง dependencies ของ custom element นั้นๆ สามารถดูรายละเอียดเพิ่มเติมของ Bower ได้ที่นี่ครับ <a href="https://bower.io/">Bower.io</a></p><p>อย่างใน <a href="https://beta.webcomponents.org/element/notwaldorf/emoji-rain">Emoji Rain README</a> ก็จะมีวิธีการติดตั้งผ่าน Bower อธิบายเอาไว้ครับ</p><pre>mkdir emoji-rain-demo &amp;&amp; cd emoji-rain-demo<br>bower install emoji-rain</pre><p><a href="https://medium.com/@zixsma/%E0%B8%AA%E0%B8%A3%E0%B9%89%E0%B8%B2%E0%B8%87-web-component-a2de58c56fb8">สร้าง Web Component</a></p><p>Keep calm and <a href="https://www.webcomponents.org/">#UseThePlatform</a><br>บทความนี้ถูกแปลมาจาก <a href="https://www.webcomponents.org/introduction">https://www.webcomponents.org/introduction</a></p><h3>ช่วงโฆษณาครับ</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*xJXlK9aISKtkPCl3u5SSMQ.png" /><figcaption>สัญลักษณ์ Web Component (ซ้าย) และ สัญลักษณ์ Polymer (ขวา)</figcaption></figure><p>ใครสนใจ Web Component สามารถ Join Facebook group <a href="https://www.facebook.com/groups/282466182190660/">Polymer and Web Component Developer Thailand</a> ใน Facebook เพื่อมาคุยกันได้นะครับ</p><p>ปล. Web Component สามารถเอาไปใช้กับทุกเฟรมเวิคได้หมดนะ Angular, React, Vue ฯลฯ ใช้ร่วมกันได้หมดเลย</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b20301f1cd33" width="1" height="1" alt=""><hr><p><a href="https://medium.com/zarewoft/web-components-b20301f1cd33">Web Components มาตรฐานใหม่ของ Web</a> was originally published in <a href="https://medium.com/zarewoft">Zarewoft</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Debug แอพ Angular ด้วย Augury]]></title>
            <link>https://medium.com/zarewoft/augury1-b8a409eb8c3?source=rss-b80726280bf1------2</link>
            <guid isPermaLink="false">https://medium.com/p/b8a409eb8c3</guid>
            <category><![CDATA[chrome-web-dev-tools]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[debugging]]></category>
            <category><![CDATA[angular2]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Tanakrit Saisillapee]]></dc:creator>
            <pubDate>Tue, 28 Mar 2017 01:32:00 GMT</pubDate>
            <atom:updated>2018-11-24T18:33:45.889Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Oi_J4y12BYCPGL3O1QZuQQ.png" /><figcaption>Logo ของ Augury เป็นรูปพระจันทร์ ดั่งเทพธิดาพยากรณ์</figcaption></figure><p>หลายคนคงเคยเจอเหตุการณ์ที่แอพ Angular ของเราเนี่ยมันทำงานไม่เป็นตามที่เราต้องการ แล้วก็ใช้เวลาแก้นานมากกกไม่รู้ว่ามันพังตรงไหน ไล่ไฟล์โน้นไฟล์นี้ แต่เดี๋ยวก่อนครับ!! แค่คุณอ่านบทความนี้ในอีก 10 นาที ปัญหาเหล่านี้ของคุณจะหมดไป เราขอแนะนำให้คุณรู้จักกับ</p><h3>Augury</h3><p>Augury เป็น Chrome Developer Tool extension สำหรับ debugging และ profiling แอพ Angular เวอร์ชั่น 2 เป็นต้นไปครับ</p><p><strong>ฟีเจอร์เด่นๆเลยคือ<br></strong>1. ดู property และ dependency ของแต่ละ component ได้ แก้ค่าได้ด้วย<br>2. ดู router tree ที่แสดงเป็นแบบกราฟให้ดูเลย เทพมาก บอกด้วยว่าตัวไหนเป็น lazy load<br>3. ดูได้ว่าในแอพเราใช้ Module อะไรบ้าง และข้างในมีอะไรบ้าง</p><blockquote>ตัว Auguryใช้ได้กับเฉพาะ Development mode นะครับ</blockquote><p><strong>ขั้นตอนการติดตั้ง<br></strong>ติดตั้งผ่าน Chrome Web Store เลยครับ<br>1. เปิด Chrome ก่อนนะครับ เข้า Chrome Web Store แล้ว search หา augury หรือกดลิ้งค์นี้เลยครับ <a href="https://chrome.google.com/webstore/detail/augury/elgalmkoelokbchhkhacckoklkejnhcd">https://chrome.google.com/webstore/detail/augury/elgalmkoelokbchhkhacckoklkejnhcd</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cYEZ1xzYeTKjSOe-U3fc9Q.png" /><figcaption>Augury บน Chrome Web Store</figcaption></figure><p>2. เสร็จแล้วครับ ง่ายมาก เขียนทำไมนะข้อ 2</p><p><strong>วิธีการเข้า Augury</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BI45fEY92I-kRBMsnae1NQ.png" /></figure><p>1. เข้าเว็บที่พัฒนาด้วย Angular2 ของเราครับ ย้ำอีกครั้งนะครับว่าต้องเป็น development mode ถ้าใครใช้ angular cli คือต้องไม่ serve ไม่ build ด้วย <em>-prod</em> หรือ <em>-t production </em>ในตัวอย่างนี้ผมใช้เว็บที่ใช้ในงาน Frontend War นะครับ</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FszJUOmiiweOic%2Ftwitter%2Fiframe&amp;src_secure=1&amp;url=http%3A%2F%2Fgiphy.com%2Fgifs%2FszJUOmiiweOic&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FszJUOmiiweOic%2Fgiphy.gif&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="266" frameborder="0" scrolling="no"><a href="https://medium.com/media/ef293c1f8cbb87bd41c27a46c99ef3c7/href">https://medium.com/media/ef293c1f8cbb87bd41c27a46c99ef3c7/href</a></iframe><p><em>2. เปิด Developer tools ขึ้นมาครับ แล้วเลือกไปที่ Augury menu ใน developer tools เราก็จะเจอ Augury </em>แล้วครับ ถ้าไม่เจอเมนู Augury ลองปิด browser แล้วเปิดใหม่ดูนะครับ</p><p>ใน Augury จะมี 3 เมนูใหญ่ครับ ดังนี้</p><ul><li>Component Tree ไว้ดูโครงสร้างในแอพ Angular ของเราว่าข้างในมี component อะไรบ้าง ยังสามารถดู property และ dependency ของ component นั้นๆได้ด้วย</li><li>Router Tree ไว้ดูโครงสร้าง Router ของเราในรูปแบบ graph ครับ สวยงามมาก</li><li>NgModules ไว้ดูว่าในแอพเรามี module อะไรบ้าง ทั้ง module ที่เราสร้างขึ้นมา และ module ที่เรา import มาใช้งาน</li></ul><p>มาดูรายละเอียดของแต่ละส่วนกันครับ</p><h3>Component Tree</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_TmCWMnge4G6LI4T6pnlKA.png" /><figcaption>เวลาเลือก component ที่ด้านขวาจะแสดง property ต่างของ component นั้นรวมถึง dependency ด้วย</figcaption></figure><ul><li>ในหน้า Component Tree จะแสดง component เป็นลำดับขั้นครับ เราสามารถดูได้ว่าแต่ละ component มี component อะไรอยู่ข้างในอีกบ้าง</li><li>เวลาเราคลิกที่ component เรายังสามารถดู property ของ component นั้นๆได้ด้วย property ที่ว่านี่รวมไปถึง Input, Output และ Dependency ด้วยครับ</li><li>เราสามารถกดไปดู source code ของ component ได้ด้วยนะครับ แค่กด (View Source) ข้างชื่อ component</li></ul><p><strong>Properties Panel</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FLTt6yxc6DIQqk%2Ftwitter%2Fiframe&amp;src_secure=1&amp;url=http%3A%2F%2Fgiphy.com%2Fgifs%2FLTt6yxc6DIQqk&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FLTt6yxc6DIQqk%2Fgiphy.gif&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="266" frameborder="0" scrolling="no"><a href="https://medium.com/media/6da175ae8a3b1cc0c70f6103cc2017d0/href">https://medium.com/media/6da175ae8a3b1cc0c70f6103cc2017d0/href</a></iframe><ul><li>เราสามารถแก้ค่า Property ต่างๆ รวมไปถึง Input ของ componet ได้จากในส่วน Properties ได้เลยครับ</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fema8BaBGayKfm%2Ftwitter%2Fiframe&amp;src_secure=1&amp;url=http%3A%2F%2Fgiphy.com%2Fgifs%2Fema8BaBGayKfm&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fema8BaBGayKfm%2Fgiphy.gif&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="266" frameborder="0" scrolling="no"><a href="https://medium.com/media/2cfc73a142aada26a2a946b13c5e29e6/href">https://medium.com/media/2cfc73a142aada26a2a946b13c5e29e6/href</a></iframe><ul><li>ในส่วนของ Output ก็ไม่น้อยหน้า เราสามารถลองสั่ง emit event ออกไปเพื่อทดสอบการทำงานได้อีกด้วย แค่กดปุ่มสีเขียว emit แค่นั้นเอง ส่งค่าไปได้ด้วยนะ</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FtauH8lBY36fLy%2Ftwitter%2Fiframe&amp;src_secure=1&amp;url=http%3A%2F%2Fgiphy.com%2Fgifs%2FtauH8lBY36fLy&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FtauH8lBY36fLy%2Fgiphy.gif&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="290" frameborder="0" scrolling="no"><a href="https://medium.com/media/5e31d0f4dbf23275f927e61cf631d837/href">https://medium.com/media/5e31d0f4dbf23275f927e61cf631d837/href</a></iframe><ul><li>อีกฟีเจอร์นึงที่ถูกซ่อนไว้นะครับ คือเราสามารถ access เข้าไปใน component ได้จากทาง console เลย</li><li>เริ่มต้นที่เราต้องเลือก component ที่เราจะ access ในส่วน component tree ก่อน แล้วพิมพ์ $a ใน console เลยครับ</li><li>มีหลายอย่างที่เราสามารถเข้าถึงได้นะครับ แต่ตัวสำคัญและน่าจะได้ใช้กันคือตัว componentInstance ตัวนี้คือ instance ของ component เราครับ ในตัวอย่างเราสามารถเรียกฟังชั่นของ instance ได้จากใน console เลย</li></ul><blockquote>ต้องเปิด Augury ไว้นะครับถึงจะสามารถเรียก $a ได้</blockquote><p><strong>Injector Graph Panel</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OsiNO2b5oChwAumxJqNrxg.png" /><figcaption>เส้นประแสดงให้เราเห็นว่า Dependency ถูกสร้างและฉีดมาจากที่ไหนครับ</figcaption></figure><p>ในส่วนของ Injector Graph นี่หลายคนอาจจะคิดว่าไม่ได้ใช้หรอก แต่จริงๆมันมีประโยชน์มากนะครับ เราสามารถดูได้ว่า dependency ที่แต่ละ component ใช้นี่ใครเป็นคนฉีดเข้ามาให้ บางครั้งการทำงานแปลกๆของแอพก็มาจากการที่เราไม่ได้ dependency ตัวที่เราต้องการครับ เช่นเราหวังว่าจะได้ Service ตัวนึงที่แชร์ข้อมูลกันกับ component อื่น แต่เราดันไปประกาศ providers ใหม่ใน component ของเราเองทำให้ component เราฉีด dependency ตัวใหม่ที่ไม่ใช่ตัวที่ใช้กับ component ตัวอื่นมาให้</p><p>รายละเอียดเพิ่มเติมของ Dependency Injection ผมจะเขียนในบทความต่อๆไปนะครับ หากตอนนี้ใครต้องการศึกษาเรื่องนี้เพิ่มเติมสามารถอ่านได้ที่นี่ครับ<br><a href="https://angular.io/docs/ts/latest/guide/dependency-injection.html">https://angular.io/docs/ts/latest/guide/dependency-injection.html</a><br><a href="https://angular.io/docs/ts/latest/guide/hierarchical-dependency-injection.html">https://angular.io/docs/ts/latest/guide/hierarchical-dependency-injection.html</a></p><p><em>เกล็ดเล็กเกล็ดน้อย</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*Z8zA7IYPJEl3m4r7S7ih0g.png" /></figure><p>เราสามารถเลือก component บนหน้าเว็บเราผ่านทางเจ้าตัวนี้ได้นะครับ (ไม่รู้ว่าเรียกว่าอะไรผมเรียกว่า inspector tool) คลิกเลือกแล้วไปจิ้มบนเว็บเราตรง component ที่เราจะเลือก</p><h3>Router Tree</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/1*IqhjgK_ht2dCKp81H5EHhw.png" /></figure><p>ตามชื่อเลยครับอันนี้ คือแสดง route ให้เราเห็นในรูปแบบ tree ซึ่งเราจะเห็น route ที่อยู่ในแอพเราทั้งหมด</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*dlNCi8xYH2k3Lo3FdfRgpQ.gif" /><figcaption>รูปแสดง route ที่ถูกโหลดแบบ Lazy Load</figcaption></figure><p>ตัวที่น่าสนใจในส่วนนี้คือถ้า route ไหนที่เป็น Lazy Load จะมี [Lazy] เขียนไว้ครับ ถ้า module ของ Lazy Load นั้นยังไม่ถูกโหลดขึ้นมาเราก็จะไม่เห็น route ข้างใน แต่ถ้าถูกโหลดขึ้นมาแล้วก็จะเห็น route ข้างในครับ</p><h3>NgModules</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pweyGGB7XchRUl4OXfK_Dw.png" /></figure><p>ในเมนูนี้จะแสดง module ในแอพเราครับ ทั้ง Root Module, Import Module และ Feature Module จะถูกแสดงในหน้านี้หมดเลย ซึ่งการแสดงผลจะถูกแบ่งออกเป็นแต่ละ module ทำให้เราเห็นว่า module แต่ละอัน import module อะไรเข้ามาใช้บ้าง มี export, provider, declaration อะไรบ้าง เอาไว้เช็คได้นะครับเวลาเราสร้าง module มาให้คนอื่นใช้ว่าเรา export ของครบไหม มี provider หรือ import ตัวไหนที่ไม่ใช้แล้วรึเปล่า</p><h3>สรุป</h3><p>Augury เป็นเครื่องมือที่นักพัฒนา Angular ควรมีติดเครื่องไว้ครับ จะสรุปทำไมนะแบบนี้ โหลดเลยครับ<br>ใครที่อยากศึกษารายละเอียดของ Augury ลึกกว่านี้สามารถไปอ่านเพิ่มเติมได้ที่เว็บนี้เลยนะครับ <a href="https://augury.angular.io/pages/guides/">https://augury.angular.io/pages/guides/</a></p><p>สามารถเสนอแนะติชมมาได้นะครับ ใครที่ลองใช้แล้วมีอะไรอยากจะแชร์มาแชร์กันได้เลย ไม่ว่าจะเขียนเป็นบทความ หรือคอมเม้น หรือถ่ายวิดีโอวิธีการใช้ แล้วเอามาแชร์กัน ในกรุ๊ป <a href="https://www.facebook.com/groups/angularjs.th/">AngularJS Developer Thailand</a> เลยครับ ผมสิงอยู่ที่นั้น</p><h3><strong>ช่วงโฆษณาครับ</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/1*TFctmZQlw4C15mtyCwmA0Q.png" /><figcaption>Polymer Logo</figcaption></figure><p>ใครสนใจ Web Component สามารถ Join Facebook group <a href="https://www.facebook.com/groups/282466182190660/">Polymer Developer Thailand</a> ใน Facebook เพื่อมาคุยกันได้นะครับพึ่งเปิดเลย<br>ในกรุ๊ปเราไม่ได้คุยแต่เรื่อง Polymer อย่างเดียว แต่เราคุยถึงเรื่อง Web Technology ทั้งหมด เพราะตัว Polymer เองเป็นแค่ Library ในการช่วยสร้าง Web Component ดังนั้นทุกอย่างที่เป็น Standard Web Technology เกี่ยวข้องหมดครับ</p><p>ปล. Web Component สามารถเอาไปใช้กับทุกเฟรมเวิคได้หมดนะ Angular, React, Vue ฯลฯ ใช้ร่วมกันได้หมดเลย</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b8a409eb8c3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/zarewoft/augury1-b8a409eb8c3">Debug แอพ Angular ด้วย Augury</a> was originally published in <a href="https://medium.com/zarewoft">Zarewoft</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>