<?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 Jas Chen on Medium]]></title>
        <description><![CDATA[Stories by Jas Chen on Medium]]></description>
        <link>https://medium.com/@JasChen?source=rss-f1ee4e783c6f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*bTIlqfSCTNCAZEsA.jpeg</url>
            <title>Stories by Jas Chen on Medium</title>
            <link>https://medium.com/@JasChen?source=rss-f1ee4e783c6f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 05:52:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@JasChen/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[The Elm Architecture in JavaScript]]></title>
            <link>https://medium.com/@JasChen/the-elm-architecture-in-javascript-eb4d5201272b?source=rss-f1ee4e783c6f------2</link>
            <guid isPermaLink="false">https://medium.com/p/eb4d5201272b</guid>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[elm]]></category>
            <dc:creator><![CDATA[Jas Chen]]></dc:creator>
            <pubDate>Sat, 19 Nov 2016 09:55:35 GMT</pubDate>
            <atom:updated>2017-07-08T04:13:50.938Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-nc/4.0/</cc:license>
            <content:encoded><![CDATA[<p>These days I’m working on a project named <a href="https://github.com/jas-chen/elm-architecture">elm-architecture</a>, which is <a href="https://guide.elm-lang.org/architecture/">The Elm Architecture</a> implemented in JavaScript.</p><h3>Background</h3><p>I used to use <a href="http://redux.js.org/">Redux</a>. Redux is good, but after using it in my daily work for half year, I do think it is just an ultimate Flux implementation, <a href="http://staltz.com/some-problems-with-react-redux.html">it doesn’t make code better or cleaner</a>. And that’s why I started my elm-architecture project.</p><h3>Implement it in the right way</h3><p><a href="https://guide.elm-lang.org/architecture/">The Elm Architecture</a> is the architecture for Elm language. It relies on language features a lot, and that makes the code very clean.</p><p>I want to keep the taste as close as possible, trying hard not to add helper functions or magic properties. This is what I’ve made so far</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/1*ZlfrPqg12Gwgk_jLKecZcg.png" /><figcaption>The Counter example. Elm (left) vs JavaScript (right)</figcaption></figure><h3>Compare The Elm Architecture to Redux</h3><h4>Something happened: Messages vs Actions</h4><p>These are how The Elm Architecture and Redux describe “Something happened”, like events, you handle them based on their <strong>type</strong>.</p><p>In Redux, an action is a plain object, it’s type is a <em>property</em>.</p><pre>{ type: ‘INCREMENT’ }<br>{ type: ‘DECREMENT’ }</pre><p>And this is how you handle them</p><pre>switch (action.type) {<br>  case &#39;INCREMENT&#39;:<br>    return state + 1<br>  case &#39;DECREMENT&#39;:<br>    return state - 1<br>}</pre><p>However, messages in The Elm Architecture is a <em>function.</em></p><pre>function Increment() {}<br>function Decrement() {}</pre><p>And this is how you handle them</p><pre>switch (msg.constructor) {<br>  case Increment:<br>    return model + 1<br>  case Decrement:<br>    return model - 1<br>}</pre><p>There are bunch of benefits of messages as functions</p><ol><li><strong>The type of messages are NOT String</strong>. You will never misspell a message type. Even if you did, browsers will throw an Error to you immediately. Say goodbye to <a href="https://github.com/reactjs/redux/blob/master/examples/todomvc/src/constants/ActionTypes.js"><em>the huge action type constant list</em></a>.</li><li><strong>No need to write message creators</strong>. Want to create a message? just call new Increment() and you get one. In Redux, you have to write action creators <em>every time</em>, so you get &#39;INCREMENT&#39; as action type and function Increment() as it’s creator, double code to write.</li><li><strong>Messages are created automatically</strong>. Most of the time The Elm Architecture will create messages automatically, you don’t need to write new Increment()yourself, just pass Increment to handlers, let them generate messages for you.</li><li><strong>Typed language support</strong>. Since messages are instances, when using language like TypeScript, it will give you great hints and code assistance.</li></ol><h4>Side Effects: Cmd/Sub vs Middleware</h4><p>Middleware in Redux can be a mess. As a middleware user I have to make sure they applied in proper order, which one should I apply first? Are they going to conflict to each other? As a middleware author I have to think, Redux-Thunk intercepts functions, so I can’t make a middleware intercepts functions too. Also I have to remember to pass actions I don’t know to next middleware, why should I take care the action sending flow? If someone made a mistake, actions will just <em>gone</em>. So much considerations.</p><p>The Elm Architecture gives you a simple way to do side effects — cmd/sub. Unlike middleware of Redux, it’s not chain-able, each side effect manager only take care of it’s job.</p><h4>State Management: Model/Update vs Reducers</h4><p>Both Redux and The Elm Architecture take single central state approach. The difference is Redux slice state into several reducers, and The Elm Architecture only have one model with an update function (You can think it as a single reducer).</p><p>The good part of reducers is the scopes are small, you can handle them piece by piece, ideally you can even reuse them across your apps. The bad part is, you have to spend time to decide how to divide your state, if you doing it wrong, you may face scaling problems. Also you will encounter questions like <a href="http://redux.js.org/docs/faq/Reducers.html#how-do-i-share-state-between-two-reducers-do-i-have-to-use-combinereducers">How do I share state between two reducers?</a></p><p>The Elm Architecture is just simple, only one single model, no hesitation at all.</p><h4>Connect to view: Call view function vs Provider/Connect</h4><p>Redux encourages users wrap components with <em>Connect</em> component when needed. The main concept is to decouple View and State, this goal sounds great, but the price is also very high, you write more and more code such as <em>mapStateToProps</em>, <em>mapDispatchToProps, Provider</em> and <em>Connect</em> to achieve it, is it really worth it?</p><p>In The Elm Architecture, you pass model to view function to render your view. As the result view is coupled with Model. That sounds bad. But this is the idea of The Elm Architecture — no components, only view pieces.</p><blockquote><strong>We do not think in terms of reusable components.</strong> Instead, we focus on reusable <em>functions</em>…we create <strong>reusable views</strong> by breaking out helper functions to display our data.<br>— <a href="https://guide.elm-lang.org/reuse/">Scaling The Elm Architecture</a></blockquote><p>Which one is better? It depends on your needs. To me, I prefer to write less code, getting things done quickly.</p><h3>Summary</h3><p>Elm is a young language, The Elm Architecture is young as well. It has great potential, you can’t talk about modern web development without mention it. Maybe someday I’ll not able to implement it in pure JavaScript with such clean structure, who knows?</p><p>If you’re interested in using The Elm Architecture in JavaScript, or you’ve had enough writing boilerplate in Redux, <a href="https://github.com/jas-chen/elm-architecture">elm-architecture</a> is here, any contribution or feedback is welcome.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb4d5201272b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Fetch with React is an Anti-Pattern]]></title>
            <link>https://medium.com/@JasChen/using-fetch-with-react-is-an-anti-pattern-cdaf117cf183?source=rss-f1ee4e783c6f------2</link>
            <guid isPermaLink="false">https://medium.com/p/cdaf117cf183</guid>
            <category><![CDATA[best-practices]]></category>
            <category><![CDATA[ajax]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Jas Chen]]></dc:creator>
            <pubDate>Fri, 19 Aug 2016 03:35:13 GMT</pubDate>
            <atom:updated>2016-08-19T03:35:53.993Z</atom:updated>
            <content:encoded><![CDATA[<p>We all like <a href="https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API">Fetch</a>, but it just doesn’t work with React.</p><blockquote>When fetching data asynchronously, use componentWillUnmount to cancel any outstanding requests before the component is unmounted.</blockquote><p>— <a href="https://facebook.github.io/react/tips/initial-ajax.html">The official React doc</a></p><p>A pending Fetch request is not cancelable, as the result you will get an error from React when a request finished <em>after</em> the component unmounting.</p><p>So just pick another ajax library that fires cancelable request, such as <a href="https://github.com/visionmedia/superagent">SuperAgent</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cdaf117cf183" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create a progressive enhancement Tab]]></title>
            <link>https://medium.com/@JasChen/create-a-progressive-enhancement-tab-a8ae6b9145f4?source=rss-f1ee4e783c6f------2</link>
            <guid isPermaLink="false">https://medium.com/p/a8ae6b9145f4</guid>
            <category><![CDATA[progressive-enhancement]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[css]]></category>
            <dc:creator><![CDATA[Jas Chen]]></dc:creator>
            <pubDate>Tue, 01 Mar 2016 07:43:39 GMT</pubDate>
            <atom:updated>2016-03-08T03:39:51.868Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Progressive enhancement</em> is a method to build web UI, the main goal is to ensure basic functions work even when JavaScript or CSS not loaded successfully (e.g. network not stable).</p><p>In this post I’ll build a Tab UI using this method.</p><h4>HTML -&gt; CSS -&gt; JavaScript</h4><p>This is the order that browsers load assets, the best case is they all loaded, the not-so-good case is only HTML and CSS loaded, and the worst case is, only HTML loaded.</p><h4>Step 1. Make sure HTML is well organized</h4><p>If you search <em>Pure CSS Tab</em> you’ll find lots of demos, most of them use <strong>&lt;input type=radio&gt;</strong> and hook on <strong>:check</strong> in CSS. This method will display radio buttons when CSS not load, so I’ll not going to use it.</p><p>Another method is combining <strong>&lt;a href=#tab&gt; </strong>and <strong>:target</strong>, this is great because users can navigate to particular content without CSS.</p><pre>&lt;ul&gt;<br>  &lt;li&gt;&lt;a href=”#tab1&quot;&gt;Tab1&lt;/a&gt;&lt;/li&gt;<br>  &lt;li&gt;&lt;a href=”#tab2&quot;&gt;Tab2&lt;/a&gt;&lt;/li&gt;<br>  &lt;li&gt;&lt;a href=”#tab3&quot;&gt;Tab3&lt;/a&gt;&lt;/li&gt;<br>&lt;/ul&gt;<br>&lt;div id=”tab1&quot;&gt;<br>  &lt;h4&gt;Tab1&lt;/h4&gt;<br>  &lt;p&gt;Content of Tab1.&lt;/p&gt;<br>&lt;/div&gt;<br>&lt;div id=”tab2&quot;&gt;<br>  &lt;h4&gt;Tab2&lt;/h4&gt;<br>  &lt;p&gt;Content of Tab2.&lt;/p&gt;<br>&lt;/div&gt;<br>&lt;div id=”tab3&quot;&gt;<br>  &lt;h4&gt;Tab3&lt;/h4&gt;<br>  &lt;p&gt;Content of Tab3.&lt;/p&gt;<br>&lt;/div&gt;</pre><p>That’s my HTML, neat!</p><h4>Step 2. Add CSS</h4><p>I just found out the Tab component of Bootstrap uses the same HTML markup as I did, why not base on Bootstrap CSS? That’s do it!</p><p>First, add bootstrap.css</p><pre>&lt;link rel=&quot;stylesheet&quot; href=&quot;<a href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css</a>&quot;&gt;</pre><p>And then modify HTML code a little bit</p><pre>&lt;ul class=”nav nav-tabs”&gt;<br>  &lt;li&gt;&lt;a href=”#tab1&quot;&gt;Tab1&lt;/a&gt;&lt;/li&gt;<br>  &lt;li&gt;&lt;a href=”#tab2&quot;&gt;Tab2&lt;/a&gt;&lt;/li&gt;<br>  &lt;li&gt;&lt;a href=”#tab3&quot;&gt;Tab3&lt;/a&gt;&lt;/li&gt;<br>&lt;/ul&gt;<br>&lt;div class=”tab-content”&gt;<br>  &lt;div id=”tab1&quot; class=”tab-pane”&gt;<br>    &lt;h4&gt;Tab1&lt;/h4&gt;<br>    &lt;p&gt;Content of Tab1.&lt;/p&gt;<br>  &lt;/div&gt;<br>  &lt;div id=”tab2&quot; class=”tab-pane”&gt;<br>    &lt;h4&gt;Tab2&lt;/h4&gt;<br>    &lt;p&gt;Content of Tab2.&lt;/p&gt;<br>  &lt;/div&gt;<br>  &lt;div id=”tab3&quot; class=”tab-pane”&gt;<br>    &lt;h4&gt;Tab3&lt;/h4&gt;<br>    &lt;p&gt;Content of Tab3.&lt;/p&gt;<br>  &lt;/div&gt;<br>&lt;/div&gt;</pre><p>At this moment content blocks are not showing, that is because I didn’t add bootstrap.js. Let’s do it in pure CSS!</p><pre>.nav-tabs {<br>  display: flex;<br>  flex-direction: row-reverse;<br>  justify-content: flex-end;<br>}</pre><pre>.tab-pane,<br>.tab-pane:target ~ .tab-pane:last-child {<br>  display: none;<br>}</pre><pre>.tab-pane:target,<br>.tab-pane:last-child {<br>  display: block;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/287/1*1b1qSoE2vYvj176FTulW_Q.gif" /><figcaption>Pure CSS Bootstrap Tab.</figcaption></figure><p>As you see, the order of the Tab is reversed, that is a trad off to make it work in pure CSS. My first attempt is moving the first content block (Content of Tab1) to be after the last content block (Content of Tab3), as described in <a href="http://trevan.co/a-pure-css-approach-to-tabs/">A Pure CSS Approach to Tabs</a>, which works fine but not so clear.</p><p>After reading <a href="http://zellwk.com/blog/star-rating/">Star Rating Re-imagined with Flexbox</a>, I realized flexbox can help in this case, so I rewrote CSS and put tab blocks into the same order as tab pills. That looks good with or without CSS.</p><h4>Final Step. Add JavaScript</h4><p>Currently this tab pills don’t have style when active, let’s add some JavaScript to complete it.</p><pre>function bindNavTabs(navTabs) {<br>  var a;<br> <br>  if (location.hash.length) {<br>    a = navTabs.querySelector(‘a[href=”#’ + location.hash + ‘”]’);<br>  }</pre><pre>  if (!a) {<br>    allAnchor = navTabs.querySelectorAll(‘a’);<br>    a = allAnchor[allAnchor.length-1];<br>  }</pre><pre>  a.parentNode.classList.add(‘active’);</pre><pre>  navTabs.addEventListener(‘click’, function(e) {<br>    if (e.target.tagName === ‘A’) {<br>      navTabs.querySelector(‘.active’).classList.remove(‘active’);<br>      e.target.parentNode.classList.add(‘active’);<br>    }<br>  });<br>}</pre><pre>var allNavTabs = document.querySelectorAll(‘.nav-tabs’);</pre><pre>for (i = 0; i &lt; allNavTabs.length; i++) {<br> bindNavTabs(allNavTabs[i]);<br>}</pre><p>All together on CodePen:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2Fjaschen%2Fembed%2Fpreview%2FwMZooq%3Fheight%3D600%26slug-hash%3DwMZooq%26default-tab%3Dresult%26host%3Dhttp%253A%252F%252Fcodepen.io&amp;url=https%3A%2F%2Fcodepen.io%2Fjaschen%2Fpen%2FwMZooq&amp;image=https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fi.cdpn.io%2F330893.wMZooq.small.25261778-f6a4-4dd8-8351-ef52cdc91ce0.png&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/bcf69ce139fd11065ba2c03d3c85e424/href">https://medium.com/media/bcf69ce139fd11065ba2c03d3c85e424/href</a></iframe><p>That’s it!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8ae6b9145f4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Proposal not selected]]></title>
            <link>https://medium.com/@JasChen/proposal-was-not-selected-277b14ee870d?source=rss-f1ee4e783c6f------2</link>
            <guid isPermaLink="false">https://medium.com/p/277b14ee870d</guid>
            <dc:creator><![CDATA[Jas Chen]]></dc:creator>
            <pubDate>Thu, 17 Dec 2015 02:31:09 GMT</pubDate>
            <atom:updated>2015-12-17T02:36:29.590Z</atom:updated>
            <content:encoded><![CDATA[<p>Submitted a proposal to React.js Conf 2016 but not selected...</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/581/1*0fJU2ONJUzXSQ2KIivfYmA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=277b14ee870d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lazymorphic Applications — the Future of the Web?]]></title>
            <link>https://medium.com/@JasChen/lazymorphic-applications-the-future-of-the-web-aeacf1fdd21a?source=rss-f1ee4e783c6f------2</link>
            <guid isPermaLink="false">https://medium.com/p/aeacf1fdd21a</guid>
            <category><![CDATA[lazymorphic-applications]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[isomorphic-applications]]></category>
            <dc:creator><![CDATA[Jas Chen]]></dc:creator>
            <pubDate>Thu, 12 Nov 2015 10:12:37 GMT</pubDate>
            <atom:updated>2015-11-13T06:45:39.629Z</atom:updated>
            <content:encoded><![CDATA[<p>Universal/Isomorphic apps is the future of the Web? I don’t think so.</p><h4>More code</h4><p>Some say Isomorphic is the Holy Grail of building web applications, sharing the code between front-end side and server side, that sounds great... really?</p><p>Code structure will looks like this</p><pre>+ client<br>+ server<br>+ shared</pre><p>But before Isomorphic, code structure looks like this</p><pre>+ client</pre><p>That is much better.</p><h4>More concerns</h4><p>Isomorphic apps run in browsers and Node context, that is superb… isn’t it?</p><p>Before building Isomorphic apps, I looking for libraries/frameworks that works in IE, Chrome, Firefox, I put global variables into <em>window</em> object.</p><p>When building Isomorphic apps, I have to pick libraries/frameworks that not only works in major browsers but also Node context, e.g. isomorphic-fetch. Worse, I can’t obtain <em>window</em> or <em>document</em> like before, I end up have lots of this kind of code in my apps:</p><pre>if (__SERVER__) {<br>  bypass();<br>} else {<br>  useBrowserAPI();<br>}</pre><p>That is hard to maintain, I have to split my mind.</p><p>I believe in Isomorphic libraries/frameworks there must contain this kind of code, and they will ship to browsers, slow down the apps.</p><h4>More cost</h4><p>Suddenly I need a Node.js server to run my Isomorphic apps. Before that I use static server like AWS S3 or GitHub Pages, they are low cost or even free to use.</p><p>Node.js server, in contrast, is expensive. And it took more time to configure, what if server just shut down and I don’t notice? Maybe there are hackers trying to hijack my server? Running a Node.js server is not simple.</p><h4>Lazymorphic</h4><p>So I tried to get <strong>Pre-rendering,</strong> <strong>Single Page Application</strong> and <strong>Static Site</strong> work together, and I found this blog post <a href="https://blog.andyet.com/2015/05/18/lazymorphic-apps-bringing-back-static-web">Lazymorphic Apps: Bringing back the static web</a>, I realized <strong>Lazymorphic</strong> is what I was looking for.</p><h4>Sitepack</h4><p><a href="https://github.com/sitepack/sitepack">Sitepack</a> is my on going attempt to build Lazymorphic apps, it leverages the power of webpack, and I will build my next web application based on this project to test it out. Perhaps it is the future.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aeacf1fdd21a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My first atom package — atom-live-server]]></title>
            <link>https://medium.com/@JasChen/my-first-atom-package-atom-live-server-c808eec2f84?source=rss-f1ee4e783c6f------2</link>
            <guid isPermaLink="false">https://medium.com/p/c808eec2f84</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[atom]]></category>
            <dc:creator><![CDATA[Jas Chen]]></dc:creator>
            <pubDate>Sat, 17 Oct 2015 04:14:21 GMT</pubDate>
            <atom:updated>2015-10-17T04:14:21.266Z</atom:updated>
            <content:encoded><![CDATA[<p>From Sublime Text to WebStorm, now my main editor is Atom, it is powered by Web technology and I quite like it!</p><p>Unfortunately there is no convenience way to launch a local dev server with live reload capability (In WebStorm it just take a click to fire one), so I made a package for it!</p><p><a href="https://atom.io/packages/atom-live-server"><strong>Try it out</strong></a> and hope you like it!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c808eec2f84" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reactive React with RxJS and Redux]]></title>
            <link>https://medium.com/@JasChen/reactive-react-with-rxjs-and-redux-a65d010cc876?source=rss-f1ee4e783c6f------2</link>
            <guid isPermaLink="false">https://medium.com/p/a65d010cc876</guid>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[reactive]]></category>
            <dc:creator><![CDATA[Jas Chen]]></dc:creator>
            <pubDate>Wed, 23 Sep 2015 00:06:15 GMT</pubDate>
            <atom:updated>2015-10-19T00:58:45.137Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Releasing </em><a href="https://github.com/jas-chen/thisless-react"><strong><em>thisless React</em></strong></a><em> — Reactive React application flow with </em><a href="https://facebook.github.io/react/"><em>React</em></a><em>, </em><a href="https://github.com/Reactive-Extensions/RxJS"><em>RxJS</em></a><em> and </em><a href="https://github.com/rackt/redux"><em>Redux</em></a><em>.</em></p><p>After creating <a href="https://github.com/jas-chen/rx-redux">rx-redux</a>, I keeping trying to combine those techniques together gracefully and straightforward, and finally I have figured it out.</p><p><a href="https://github.com/jas-chen/thisless-react"><strong>thisless React</strong></a> is an application flow that</p><ul><li><strong>thisless</strong>: <em>this</em> cannot be found in <a href="https://github.com/jas-chen/thisless-react/blob/master/examples">examples</a>.</li><li><strong>Fully Reactive</strong>: With <a href="https://github.com/Reactive-Extensions/RxJS">RxJS</a> and <a href="https://github.com/jas-chen/react-reactive-class">React Reactive Class</a>, components are made reactive and observable.</li><li><strong>It’s just React</strong>: No magic! Use the technique you already know, without learning new library or API and plays well with your existing React apps.</li><li><strong>Pure View</strong>: Completely decouple View from Model, no more Model injection. Code like <em>store.dispatch(action)</em> or <em>store.getState()</em> cannot be found in View.</li><li><strong>High Performance</strong>: Introduce <em>Static Component</em> and <em>Data Binding</em> by default. React will no longer diff entire huge Virtual DOM. <em>See Vjeux’s slide </em><a href="https://speakerdeck.com/vjeux/react-rally-animated-react-performance-toolbox"><em>Animated — React Performance Toolbox</em></a><em>for more details</em>.</li></ul><p>More info is on <a href="https://github.com/jas-chen/thisless-react">Github</a>, go check it out and make your apps reactive!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a65d010cc876" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Solve React’s hardest problem: Passive API]]></title>
            <link>https://medium.com/@JasChen/solve-react-s-hardest-problem-passive-api-9d8d54d934c9?source=rss-f1ee4e783c6f------2</link>
            <guid isPermaLink="false">https://medium.com/p/9d8d54d934c9</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[reactive]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Jas Chen]]></dc:creator>
            <pubDate>Tue, 01 Sep 2015 08:23:43 GMT</pubDate>
            <atom:updated>2015-09-09T03:20:25.562Z</atom:updated>
            <content:encoded><![CDATA[<p><em>React has a problem that everyone wants to solve.</em></p><h4>The Problem</h4><p><a href="https://jsbin.com/vibiyikaga/1/edit?js,console,output">Play this demo</a>, and you will see the console messages like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*lRyNLymBeR3ETAyR1RulBw.png" /></figure><p>There are 3 components in this demo app: <strong>App</strong>, <strong>Button</strong>, <strong>Text</strong>. When Button gets clicked, they all re-rendered.</p><p>But do they all need to re-render? The only component that changed is Text, so the re-rendering of App and Button is unnecessary.</p><blockquote>Components get re-rendered, even they don’t need to.</blockquote><h4>How people solve this problem?</h4><p>Currently, there are 2 methods: Invoke <a href="https://facebook.github.io/react/docs/component-specs.html#updating-shouldcomponentupdate"><strong>shouldComponentUpdate</strong></a> to determine if this component should re-render or use <a href="https://facebook.github.io/react/docs/pure-render-mixin.html"><strong>PureRenderMixin</strong></a> if you don’t have complex data models.</p><p><em>Does the problem solved?</em> This is what I got</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*s6dE6U7ILHVbaz4HDosiDw.png" /></figure><p>Okay, Button is no longer re-rendering. What about App?</p><h4>The Actual Problem</h4><p><em>There is no way to stop App from re-rendering!</em> You said. <em>If you want to update Text, you have to update App.</em></p><p>The actual problem is here. React components are passive. They rely on ancestor components, they can’t handle themselves.</p><p>How can we save App from re-rendering?</p><h4>The Solution</h4><p><a href="https://jsbin.com/buzukutoru/1/edit?js,console,output">Take a look at this modified app</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*XhEWQspOpcXJA7229yhdzw.png" /></figure><p>How could this happen?</p><p>Well, <strong>Text</strong> receives an Event Emitter and listens to it, when new events come, it re-renders itself, and <strong>App</strong> just emits events. <strong>No more unnecessary re-rendering!</strong></p><h4>Reactive Components</h4><p>That is what I call them.<br>A <strong>reactive component</strong> can handle itself, it listens to events and also emits events, no longer forced to be updated or forcing others to update.</p><h4>Conclusion</h4><p>Say goodbye to <a href="https://facebook.github.io/react/docs/component-specs.html#updating-shouldcomponentupdate"><strong>shouldComponentUpdate</strong></a>, say goodbye to <a href="https://facebook.github.io/react/docs/pure-render-mixin.html"><strong>PureRenderMixin</strong></a>, and even say goodbye to Immutable data structures.</p><p>From now on, components will update only when they really need to.</p><blockquote>Want to use reactive components today? Take a look at my project <a href="https://github.com/jas-chen/react-reactive-class"><strong>React Reactive Class</strong></a>, it will help you create reactive components.</blockquote><h4>Inspirations</h4><p><a href="http://staltz.com/dont-react/"><strong>Don’t React</strong></a><strong><br></strong><a href="http://www.slideshare.net/MinamoPH/cycle-reactreactjstw9"><strong>Reactive React &amp; The Cycle</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9d8d54d934c9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GraphQL 之我見]]></title>
            <link>https://medium.com/@JasChen/graphql-%E4%B9%8B%E6%88%91%E8%A6%8B-86910a235ca0?source=rss-f1ee4e783c6f------2</link>
            <guid isPermaLink="false">https://medium.com/p/86910a235ca0</guid>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Jas Chen]]></dc:creator>
            <pubDate>Thu, 09 Jul 2015 04:04:15 GMT</pubDate>
            <atom:updated>2015-07-09T07:08:01.223Z</atom:updated>
            <content:encoded><![CDATA[<p>先看個範例（摘自 <a href="https://facebook.github.io/react/blog/2015/05/01/graphql-introduction.html">GraphQL Introduction</a>），這是一個查詢：</p><pre>{<br>  user(id: 3500401) {<br>    id,<br>    name,<br>    isViewerFriend,<br>    profilePicture(size: 50)  {<br>      uri,<br>      width,<br>      height<br>    }<br>  }<br>}</pre><p>而這是查詢的結果：</p><pre>{<br>  &quot;user&quot; : {<br>    &quot;id&quot;: 3500401,<br>    &quot;name&quot;: &quot;Jing Chen&quot;,<br>    &quot;isViewerFriend&quot;: true,<br>    &quot;profilePicture&quot;: {<br>      &quot;uri&quot;: &quot;http://someurl.cdn/pic.jpg&quot;,<br>      &quot;width&quot;: 50,<br>      &quot;height&quot;: 50<br>    }<br>  }<br>}</pre><p>GraphQL 是一個 Application-Layer Protocol（像是 RESTful API）的 endpoint，在我看來主要解決的痛點有2個：</p><ol><li>使用 RESTful API 時，Server 主導了資料回傳的<em>結構</em>以及<em>內容。</em>取回來的資料必須由 client 自行轉換成邏輯或是 view 合用的資料結構；有些資料用不著但 server 還是會傳給你，或是 server 回傳的資料有限/有相依性，往往要發好幾個 request 才能拿到所有資料。<br><strong>何不一開始就跟 server 說：「嘿，我要這些資料跟他的相依資料，並且請依照以下的結構傳給我。」</strong>。</li><li>由於資料的結構是由 client 決定的，所以並不會發生 api 改版的悲劇（你要取的資料已經改名/換位置了）。</li></ol><h4>參考資料</h4><p><a href="http://facebook.github.io/graphql/">GraphQL 官網</a><br><a href="https://facebook.github.io/react/blog/2015/05/01/graphql-introduction.html">GraphQL Introduction</a><br><a href="https://www.youtube.com/watch?v=WQLzZf34FJ8">Lee Byron — Exploring GraphQL at react-europe 2015</a><br><a href="https://www.youtube.com/watch?v=IrgHurBjQbg">Joseph Savona — Relay: An Application Framework For React at react-europe 2015</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=86910a235ca0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Whole New Page]]></title>
            <link>https://medium.com/@JasChen/a-whole-new-page-f621a524a05f?source=rss-f1ee4e783c6f------2</link>
            <guid isPermaLink="false">https://medium.com/p/f621a524a05f</guid>
            <category><![CDATA[startup]]></category>
            <dc:creator><![CDATA[Jas Chen]]></dc:creator>
            <pubDate>Tue, 07 Jul 2015 09:13:19 GMT</pubDate>
            <atom:updated>2015-07-07T09:19:16.773Z</atom:updated>
            <content:encoded><![CDATA[<p>After working 6 months at a cloud company, I decide to quit and do what I really want to do — build a website about how to write code.</p><p>This is a whole new page, sent from my little studio.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f621a524a05f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>