<?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 Mike Ryan on Medium]]></title>
        <description><![CDATA[Stories by Mike Ryan on Medium]]></description>
        <link>https://medium.com/@MikeRyanDev?source=rss-d6ba4dcb6838------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*4Q9Sf13DmmK0NP5OFKioHg.jpeg</url>
            <title>Stories by Mike Ryan on Medium</title>
            <link>https://medium.com/@MikeRyanDev?source=rss-d6ba4dcb6838------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 00:19:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@MikeRyanDev/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 TypeScript Gluten Behind NgRx createActionGroup]]></title>
            <link>https://medium.com/@MikeRyanDev/the-typescript-gluten-behind-ngrx-createactiongroup-772f7b8b8045?source=rss-d6ba4dcb6838------2</link>
            <guid isPermaLink="false">https://medium.com/p/772f7b8b8045</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[ngrx]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[open-source]]></category>
            <dc:creator><![CDATA[Mike Ryan]]></dc:creator>
            <pubDate>Fri, 08 Jul 2022 16:46:19 GMT</pubDate>
            <atom:updated>2022-07-08T16:46:19.633Z</atom:updated>
            <content:encoded><![CDATA[<p>Creating strongly typed APIs in TypeScript relies on understanding advanced typing strategies. NgRx heavily depends on typing strategies such as string literal types, conditional types, and template literal types to create an API surface that encourages consumers to build strongly typed applications. Let’s take a look at an example API in the NgRx codebase to see how NgRx leverages these advanced typing techniques.</p><p><a href="https://dev.to/ngrx/ngrx-action-group-creator-1deh">NgRx v13.2</a> introduces a new function for defining groups of actions:</p><pre>const AuthApiActions = createActionGroup({<br>  source: &#39;Auth API&#39;,<br>  events: {<br>    &#39;Login Success&#39;: props&lt;{ user: UserModel }&gt;(),<br>    &#39;Login Failure&#39;: props&lt;{ error: AuthError }&gt;(),<br>  },<br>});</pre><p>The type of AuthApiActions becomes an object containing methods for instantiating actions for each of the configured events:</p><pre>this.store.dispatch(AuthApiActions.loginFailure({ error }));</pre><p>What excites me the most about this new API is that it is <strong>100% type-safe</strong>. How do we get from ‘Login Success’ to loginSuccess on the function names though? TypeScript’s type literal type manipulation!</p><h3>Going from ‘Event Name’ to eventName with TypeScript</h3><p>NgRx Store’s codebase contains a utility type alias that converts &#39;Event Name&#39; to eventName:</p><pre>export type ActionName&lt;EventName extends string&gt; = Uncapitalize&lt;<br>  RemoveSpaces&lt;Titlecase&lt;Lowercase&lt;Trim&lt;EventName&gt;&gt;&gt;&gt;<br>&gt;;</pre><p>ActionName is doing all of the heavy lifting to convert event names at the type level by:</p><ol><li>Starting with a string literal type (EventName extends string)</li><li>Trimming it</li><li>Making it lowercase</li><li>Titlecasing each segment of the string</li><li>Removing the spaces between words</li><li>Lowercasing the first letter</li></ol><p>There is a lot going on here, so let’s break it down step-by-step!</p><h3>1. String Literal Types</h3><p>My experience with advanced types in TypeScript is that advanced types are extremely relevant when writing libraries and not as relevant in application code. One core concept of advanced typing in TypeScript that library authors often take heavy advantage of is string literal types. If you haven’t encountered them before, a string literal type is a string type but narrowed down to a specific string.</p><p>This will be a little easier to explain with examples. Let’s say we have a function that takes the name of a kind of bread and prints it to the console:</p><pre>function bakeBread(kindOfBread: string) {<br>  console.log(`🥖 Baking: ${kindOfBread}`);<br>}</pre><p>There’s a problem with this function. I can pass this function any string and TypeScript won’t care:</p><pre>bakeBread(&#39;Pie&#39;);</pre><p>String literal types let us specify a concrete subtype of string to enforce correctness. For example, if we wanted to limit the type of kindOfBread to &quot;Wheat&quot; we could do this:</p><pre>function bakeBread(kindOfBread: &#39;Wheat&#39;) {<br>  console.log(`🥖 Baking: ${kindOfBread}`;<br>}</pre><p>Now if we try to pass in a string that is not a kind of bread we get a type error:</p><pre>bakeBread(&#39;Cake&#39;);</pre><p>This produces the error:</p><pre>Argument of type &amp;#39;&amp;quot;Cake&amp;quot;&amp;#39; is not assignable to parameter of type &amp;#39;&amp;quot;Wheat&amp;quot;&amp;#39;.(2345)</pre><p>Obviously, there are more types of cake than just &quot;Wheat&quot; though. By creating a union type of string literals, we can constrain the type of kindOfBread to be the kinds of bread that our program is aware of:</p><pre>type KindsOfBread =<br>  | &#39;Wheat&#39;<br>  | &#39;White&#39;<br>  | &#39;Rye&#39;<br>  | &#39;Pumperknickel&#39;<br>  | &#39;Sourdough&#39;<br>  | &#39;Banana&#39;;</pre><pre>function bakeBread(kindOfBread: KindsOfBread) {<br>  console.log(`🥖 Baking: ${kindOfBread}`;<br>}</pre><p>Now we can call bakeBread with a variety of valid bread types without error:</p><pre>bakeBread(&#39;Rye&#39;);<br>bakeBread(&#39;Sourdough&#39;);<br>bakeBread(&#39;Banana&#39;);</pre><p>And if we try to pass in a kind of bread that our program is not aware of we get a type error:</p><pre>bakeBread(&#39;Pound Cake&#39;);</pre><p>This results in:</p><pre>Argument of type &amp;#39;&amp;quot;Pound Cake&amp;quot;&amp;#39; is not assignable to parameter of type &amp;#39;KindsOfBread&amp;#39;.(2345)</pre><h3>2. Trimming String Literal Types</h3><p>NgRx’s ActionName operates on string literal types. From here, it starts applying advanced typing on string literal types to coerce a string literal type of &quot;Event Name&quot; into &quot;eventName&quot;.</p><p>The first step is to trim the string literal types, or, in other words, remove any surrounding whitespace. That way, if the developer passes in a string like &quot; Event Name&quot; we don’t produce a function whose name is eventName.</p><p>To strip the whitespace around a string literal type, we are going to have to use <strong>conditional types</strong>. A conditional type is a type that checks if a condition is true or not at the <em>type level</em> and can conditionally return a different type as a result of the condition.</p><p>Let’s take a look at example code!</p><pre>interface SliceOfBread {<br>  toast(): void;<br>}</pre><pre>interface SliceOfCake {<br>  frost(): void;<br>}</pre><pre>interface Bread {<br>  slice(): SliceOfBread;<br>}</pre><pre>interface Cake {<br>  slice(): SliceOfCake;<br>}</pre><p>In this example, our program has interfaces for Cake and Bread both of which have a slice() method for producing SliceOfCake and SliceOfBread respectively.</p><p>Now let’s write a function called slice that takes an object of type Cake or Bread and returns the right result:</p><pre>function slice(cakeOrBread: Cake | Bread): ??? {<br>  return cakeOrBread.slice();<br>}</pre><p>What type should we use for the return type of this function? Naively, we could use SliceOfCake | SliceOfBread:</p><pre>function slice(cakeOrBread: Cake | Bread): SliceOfCake | SliceOfBread {<br>  return cakeOrBread.slice();<br>}</pre><p>This would require the consumer of slice to inspect the return type to know if it got back a slice of cake or a slice of bread. For example, if we tried to toast a slice of bread we get back when passing in pumperknickel:</p><pre>slice(pumperknickel).toast();</pre><p>We get an error back from the TypeScript compiler:</p><pre>Property &amp;#39;toast&amp;#39; does not exist on type &amp;#39;SliceOfCake | SliceOfBread&amp;#39;.<br>  Property &amp;#39;toast&amp;#39; does not exist on type &amp;#39;SliceOfCake&amp;#39;.(2339)</pre><p>We could use function overloads to write slice in a way that works correctly:</p><pre>function slice(cake: Cake): SliceOfCake;<br>function slice(bread: Bread): SliceOfBread;<br>function slice(cakeOrBread: Cake | Bread): SliceOfCake | SliceOfBread {<br>  return cakeOrBread.slice();<br>}</pre><p>This removes the type errors and all of the types are inferred correctly. However, we can shorten this by leveraging <em>conditional types</em>. Let’s write a type alias that takes in a type T and converts it into a SliceOfCake if T is Cake or never if T is not Cake:</p><pre>type Slice&lt;T&gt; = T extends Cake ? SliceOfCake : never;</pre><p>As you can see, conditional types borrow their syntax from ternary expressions in JavaScipt. Now if we pass in Cake (or any subtype of Cake) to Slice we get back SliceOfCake:</p><pre>type Result = Slice&lt;Cake&gt; // Returns &quot;SliceOfCake&quot;</pre><p>We can nest conditional expressions to make Slice aware of both Bread and Cake:</p><pre>type Slice&lt;V&gt; = V extends Cake<br>  ? SliceOfCake<br>  : V extends Bread<br>    ? SliceOfBread<br>    : never;</pre><p>Now if we pass in Bread or Cake to Slice get back SliceOfBread or SliceOfCake, respectively:</p><pre>type Result1 = Slice&lt;Bread&gt; // &quot;SliceOfBread&quot;<br>type Result2 = Slice&lt;Cake&gt; // &quot;SliceOfCake&quot;<br>type Result3 = Slice&lt;Cereal&gt; // &quot;never&quot;</pre><p>We can use conditional types in combination with string literal types to start producing functions with powerful type inference.</p><p>Let’s take our KindsOfBread type from earlier and compliment it with a KindsOfCake type to rewrite Slice, only this time Slice will take in a string literal type and produce either SliceOfBread if we pass in a kind of bread or SliceOfCake if we pass in a kind of cake:</p><pre>type KindsOfBread =<br>  | &#39;Wheat&#39;<br>  | &#39;White&#39;<br>  | &#39;Rye&#39;<br>  | &#39;Pumperknickel&#39;<br>  | &#39;Sourdough&#39;<br>  | &#39;Banana&#39;;</pre><pre>type KindsOfCake =<br>  | &#39;Vanilla&#39;<br>  | &#39;Chocolate&#39;<br>  | &#39;Strawberry&#39;<br>  | &#39;Pound&#39;<br>  | &#39;Coffee&#39;;</pre><pre>type Slice&lt;T&gt; = T extends KindsOfBread<br>  ? SliceOfBread<br>  : T extends KindsOfCake<br>    ? SliceOfCake<br>    : never;</pre><p>Let’s see what we get back now:</p><pre>type Result1 = Slice&lt;&#39;Banana&#39;&gt; // &quot;SliceOfBread&quot;<br>type Result2 = Slice&lt;&#39;Vanilla&#39;&gt; // &quot;SliceOfCake&quot;<br>type Result3 = Slice&lt;&#39;Tuna&#39;&gt; // &quot;never&quot;</pre><p>This works great, but there’s still an <em>aesthetic</em> problem with the code. No one writes out “Vanilla” or “Banana” and expects you to know they are talking about cakes and breads. Aesthetically, this code would be more pleasing if we wrote it out like this:</p><pre>type Result1 = Slice&lt;&#39;Banana Bread&#39;&gt;;<br>type Result2 = Slice&lt;&#39;Vanilla Cake&#39;&gt;;<br>type Result3 = Slice&lt;&#39;Tuna Fish&#39;&gt;;</pre><p>How can we extract the first part of the string literal types (the <em>kind</em>) to figure out what we are returning? In TypeScript, expressions passed to conditional types can use inference to <em>infer</em> new types.</p><p>To take advantage of this, let’s write out a type for the categories of foods our application supports:</p><pre>type Foods = &#39;Bread&#39; | &#39;Cake&#39; | &#39;Fish&#39;;</pre><p>Now let’s write a type that extracts the <em>kind</em> modifier from a type literal like &quot;Tuna Fish&quot;:</p><pre>type ExtractKind&lt;V&gt; = V extends `${infer Kind} ${Foods}`<br>  ? Kind<br>  : never;</pre><p>What’s this doing? We are testing if the type parameter V is a string literal type in the format of ${Kind} ${Foods}. For example, if we pass in &quot;Tuna Fish&quot; we will get back &quot;Tuna&quot; as the inferred type Kind. If we pass in just &quot;Tuna&quot; we will get back never since the string literal type &quot;Tuna&quot; is not in the format of &quot;Tuna Fish&quot;. Using this, we can now improve the aesthetics of Slice:</p><pre>type Slice&lt;T, V = ExtractKind&lt;T&gt;&gt; = V extends KindsOfBread<br>  ? SliceOfBread<br>  : V extends KindsOfCake<br>    ? SliceOfCake<br>    : never;</pre><pre>type Result1 = Slice&lt;&#39;Banana Bread&#39;&gt; // &quot;SliceOfBread&quot;<br>type Result2 = Slice&lt;&#39;Vanilla Cake&#39;&gt; // &quot;SliceOfCake&quot;<br>type Result3 = Slice&lt;&#39;Tuna Fish&#39;&gt; // &quot;never&quot;</pre><p>NgRx’s ActionName needs to trim string literal types before doing any further conversion. It’s trimming strings by applying the exact same string inference trick that our ExtractKind utility is using by recursively inferring the string surrounded by whitespace:</p><pre>type Trim&lt;T extends string&gt; = T extends ` ${infer R}`<br>  ? Trim&lt;R&gt;<br>  : T extends `${infer R} `<br>    ? Trim&lt;R&gt;<br>    : T;</pre><p>If you pass in &quot; Banana Cake &quot; to Trim you get back &quot;Banana Cake&quot;. Powerful TypeScript magic!</p><h3>3. Lowercasing String Literal Types</h3><p>With our bread sliced and our strings trimmed, we are ready to move on to the next bit of TypeScript behind ActionName: lowercasing string literal types!</p><p>How could we get from &quot;Banana Bread&quot; to &quot;banana bread&quot;? We could write out a very long and complex conditional type that maps each uppercase character into a lowercase character. Thankfully, however, TypeScript gives us a Lowercase utility type out-of-the-box. 🙂</p><pre>type Result = Lowercase&lt;&quot;Banana Bread&quot;&gt; // &quot;banana bread&quot;</pre><p>Lowercasing? Easy! TypeScript ships with four utility types for manipulating string literal types:</p><ul><li>Lowercase&lt;&quot;Banana Bread&quot;&gt; to produce &quot;banana bread&quot;</li><li>Uppercase&lt;&quot;Banana Bread&quot;&gt; to produce &quot;BANANA BREAD&quot;</li><li>Capitalize&lt;&quot;banana&quot;&gt; to produce &quot;Banana&quot;</li><li>Uncapitalize&lt;&quot;BANANA&quot;&gt; to produce &quot;bANANA&quot;</li></ul><h3>4. Titlecasing String Literal Types</h3><p>TypeScript ships with utility types to lowercase, uppercase, capitalize, and uncapitalize string literal types. It does not include string literal types to do more advanced string manipulation.</p><p>For NgRx, we ultimately want to convert a string of words describing an event into a camelCased function name. To get there, we need to first convert the words into title case. In other words, go from &quot;banana bread&quot; to &quot;Banana Bread&quot;.</p><p>Before we build a titlecasing type utility, we need to explore <em>template literal types</em>. A template literal type is a supercharged string literal type that uses string interpolation syntax to create new string literal types. In our program, we have a KindsOfBread type that is a union of all of the kinds of breads our program is aware of. We could expand this into a type that includes the word &quot;Bread&quot; by using a template literal type:</p><pre>type Bread = `${KindsOfBread} Bread`;</pre><p>This would be the same as writing:</p><pre>type Bread =<br>  | &quot;Wheat Bread&quot;<br>  | &quot;White Bread&quot;<br>  | &quot;Rye Bread&quot;<br>  | &quot;Pumperknickel Bread&quot;<br>  | &quot;Sourdough Bread&quot;<br>  | &quot;Banana Bread&quot;;</pre><p>Using template literal types, we can strengthen the clarity of our Slice type:</p><pre>type Bread = `${KindsOfBread} Bread`;<br>type Cake = `${KindsOfCake} Cake`;</pre><pre>type Slice&lt;T extends Bread | Cake, V = ExtractKind&lt;T&gt;&gt; = V extends KindsOfBread<br>  ? SliceOfBread<br>  ? V extends KindsOfCake<br>    ? SliceOfCake<br>    : never;</pre><p>Our types continue to infer correctly:</p><pre>type Result1 = Slice&lt;&#39;Banana Bread&#39;&gt; // SliceOfBread<br>type Result2 = Slice&lt;&#39;Coffee Cake&#39;&gt; // SliceOfCake</pre><p>And now if we try to pass in a food item that is not bread or cake we get a better error:</p><pre>Type &amp;#39;&amp;quot;Tuna Fish&amp;quot;&amp;#39; does not satisfy the constraint &amp;#39;&amp;quot;Wheat Bread&amp;quot; | &amp;quot;White Bread&amp;quot; | &amp;quot;Rye Bread&amp;quot; | &amp;quot;Pumperknickel Bread&amp;quot; | &amp;quot;Sourdough Bread&amp;quot; | &amp;quot;Banana Bread&amp;quot; | &amp;quot;Vanilla Cake&amp;quot; | &amp;quot;Chocolate Cake&amp;quot; | &amp;quot;Strawberry Cake&amp;quot; | &amp;quot;Pound Cake&amp;quot; | &amp;quot;Coffee Cake&amp;quot;&amp;#39;.</pre><p>Template literal types let us <em>expand</em> unions of string literal types into new unions of string literals. We can build a titlecasing type utility using TypeScript’s built-in string literal type utilities, conditional types, and template literal types:</p><pre>type Titlecase&lt;T extends string&gt; = T extends `${infer First} ${infer Rest}`<br>  ? `${Capitalize&lt;First&gt;} ${Titlecase&lt;Rest&gt;}`<br>  : Capitalize&lt;T&gt;;</pre><p>Our Titlecase utility is doing the following:</p><ol><li>Splitting up a string like &quot;banana nut bread&quot; into two types, First which is &quot;banana&quot; and Rest which is &quot;nut bread&quot;</li><li>It passes First to Capitalize and Rest to Titlecase for recursive processing</li><li>Once it gets to the very last word in the string literal type (in this case &quot;bread&quot;) it passes it to Capitalize</li></ol><p>Now we can convert any string literal type into a titlecased string literal type:</p><pre>type Result = Titlecase&lt;&quot;banana nut bread&quot;&gt; // &quot;Banana Nut Bread&quot;</pre><h3>5. Removing Spaces Between Words</h3><p>We can convert a string literal type that uses mixed casing with padded whitespace into a trimmed, titlecased string using the builtin Lowercase and our handwritten Trim and Titlecase type aliases:</p><pre>type R = Titlecase&lt;Lowercase&lt;Trim&lt;&quot;  banana NUT bread &quot;&gt;&gt;&gt; // &quot;Banana Nut Bread&quot;</pre><p>We are still trying to get this to be in the form of &quot;bananaNutBread&quot; meaning we have to strip the spaces between words. Thankfully, we don’t need to learn any new tricks. We have everything we need with conditional types and template literal types:</p><pre>type RemoveSpaces&lt;T extends string&gt; = T extends `${infer First} ${infer Rest}`<br>  ? `${First}${RemoveSpaces&lt;Rest&gt;}`<br>  : T;</pre><p>This is very similar to Titlecase, only this time we are not doing any additional string manipulation. All this type utility does is take a string literal type in the form of &quot;Banana Nut Bread&quot; and convert it into &quot;BananaNutBread&quot;.</p><h3>6. Lowercasing the First Letter</h3><p>We are <em>so close</em> now to having the ability to go from &quot; banana NUT bread &quot; to &quot;bananaNutBread&quot;. All we are missing is a way to uncapitalize the first letter. And if you recall, TypeScript ships with a type utility to do just that! Now we can write out our full ActionName utility using the built-in Lowercase and Uncapitalize in combination with our Trim, Titlecase, and RemoveSpaces type utilities:</p><pre>type ActionName&lt;T extends string&gt; =<br>  Uncapitalize&lt;RemoveSpace&lt;Titlecase&lt;Lowercase&lt;Trim&lt;T&gt;&gt;&gt;&gt;&gt;</pre><p>🥳🎉🥖</p><h3>Conclusion</h3><p>NgRx’s createActionGroup relies on advanced TypeScript typing to convert the names of events into strongly-typed function names. It is able to cast from &quot;Event Name&quot; to &quot;eventName&quot; through a combination of string literal types, conditional types, and template literal types. I want to give a huge shout out to <a href="https://dev.to/markostanimirovic">Marko Stanimirović</a> for turning this concept into a fully functioning and well tested NgRx feature. Check out the full source code if you want to see the rest of the type magic going on under-the-hood of createActionGroup.</p><p>LiveLoveApp provides technical leadership and can help your organization improve code quality and software architecture — including using TypeScript (with any framework). Learn more at <a href="http://liveloveapp.com/">LiveLoveApp.com</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=772f7b8b8045" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Announcing the Release of NgRx 6, New Projects, and Looking Ahead]]></title>
            <link>https://medium.com/ngrx/announcing-the-release-of-ngrx-6-new-projects-and-looking-ahead-5fc30bed260b?source=rss-d6ba4dcb6838------2</link>
            <guid isPermaLink="false">https://medium.com/p/5fc30bed260b</guid>
            <category><![CDATA[rxjs]]></category>
            <category><![CDATA[ngrx]]></category>
            <category><![CDATA[angularjs]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Mike Ryan]]></dc:creator>
            <pubDate>Wed, 23 May 2018 13:14:38 GMT</pubDate>
            <atom:updated>2018-05-23T19:37:25.638Z</atom:updated>
            <content:encoded><![CDATA[<p>Today we are excited to announce the official release of v6 of the NgRx framework. This release is jam packed with bug fixes and improvements to our Schematics package. We have focused on trying to make the upgrade as smooth as possible with very few breaking changes. You can view the <a href="https://github.com/ngrx/platform/blob/master/CHANGELOG.md">full change log</a> for a list of all of the bug fixes and breaking changes.</p><p>If you are using the CLI, upgrading is as easy as ng update @ngrx/store. This will update all of your NgRx packages to v6 including Effects, Schematics, Entity, Router Store, and Store Devtools.</p><h3>New Projects</h3><p>While there are very few user facing features in NgRx 6 this release was a major milestone for us. We have updated our build process to Bazel, we are committing to unifying our major version number with Angular, and we have strengthened our integration with the Angular CLI by introducing full support for theng add and ng update commands.</p><p>We have big plans for the near future of NgRx. This summer we will be working on NgRx.io, a brand new documentation resource for NgRx. Not only will this be the new home for our documentation and examples but we plan on launching an official NgRx style guide and collection of best practices to help teams be more productive with NgRx.</p><p>We have also begun planning out the NgRx 7 release. There is a milestone on the NgRx Platform repository that captures all of the new and exciting enhancements we are planning that <a href="https://github.com/ngrx/platform/projects/6">you can find here</a>. Highlights include better runtime development checks, builtin support for state hydration/serialization, improved type inference for Effects, and a variety of enhancements to NgRx Entity.</p><p>Also new in NgRx 7 will be the recently announced NgRx Data package by John Papa and Ward Bell. We are well aware that the explicitness that NgRx demands of developers causes slow development cycles and makes it hard to get started with NgRx quickly (“Boilerplate!”). John and Ward’s NgRx Data package simplifies the startup process by automatically integrating NgRx with your REST API; no actions, reducers, effects, or selectors required. Checkout the <a href="https://youtu.be/t3jx0EC-Y3c?t=34m42s">end of our ng-conf 2018 talk “Reducing the Boilerplate with NgRx”</a> to learn more about NgRx Data. We are excited to fold NgRx Data into the NgRx framework later this year.</p><h3>Looking Ahead</h3><p>NgRx.io, NgRx Data, and NgRx 7 gives you a roadmap of what to expect in the next six to nine months but what about beyond that? One of the biggest changes coming to Angular is the introduction of Renderer 3 — aka Ivy. Our friend Max at Angular in Depth <a href="https://blog.angularindepth.com/ivy-engine-in-angular-first-in-depth-look-at-compilation-runtime-and-change-detection-876751edd9fd">has a great write up of what’s changing</a> with this new renderer.</p><p>What excites the NgRx team about Ivy is that will enable us to introduce functional reactivity to even more parts of the Angular framework. NgRx has not always been just state management; some of our earlier packages provided reactive APIs for notifications, local storage, and routing. Over time we’ve deprecated some of these libraries and others — like NgRx Router — have been integrated directly into the Angular framework itself.</p><p>With Ivy we are excited to return to our roots and introduce more functional reactive libraries for Angular beyond state management. Expect us to start looking at introducing libraries for handling forms, routing, and components in the not-too-distant future.</p><h4>Not Going At This Alone</h4><p>The NgRx team is growing! We are excited to announce that <a href="https://twitter.com/wardbell">Ward Bell</a> and <a href="https://twitter.com/tim_deschryver">Tim Deschryver</a> are joining the NgRx team. Ward joins us to help build out and support NgRx Data as well as help us shape NgRx.io. Tim joins us to continue doing an excellent job supporting developers and building out the platform. Brandon, Rob, Victor, and myself will remain actively involved in planning, growing, and developing NgRx.</p><h4>NgRx at ng-conf 2018!</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*OK3PCV7-j-dEj1da." /></figure><p>NgRx was provided a full fair-day track at ng-conf 2018, and we were very excited to see all the great talks and workshops. If you haven’t watched all the videos by the NgRx core team you can watch the <a href="https://www.youtube.com/playlist?list=PL8OUS498tQP3FFsZzULTGnbyIcILFjHd3">entire playlist</a> here.</p><p>We plan on attending even more events throughout 2018. You can find us at WeRise Tech, Framework Summit, and AngularConnect just to name a few. Head on over to the <a href="https://github.com/ngrx/platform">NgRx Platform repository</a> to find a full list of all the events and meet-ups that we will be attending. If you are at one of those events please come say hello and grab an NgRx sticker! We love engaging with developers that use NgRx .</p><h4>Thank You for Your Support</h4><p>This release was truly collaborative and we would like to take a minute to thank everyone who submitted pull requests and bug reports; you really helped shape this release. We would like to call out in particular Alex Eagle for his tremendous help in moving us to Bazel, Vitalii Bobrov for helping with Schematics integration and San Nguyen for the extra effort with issue triaging and pull requests.</p><p>We also greatly appreciate the continued support for NgRx from our backers and sponsors on OpenCollective. The support aids in the development time and effort put into the NgRx framework. If you haven’t already, consider backing or sponsoring NgRx <a href="https://opencollective.com/ngrx">through the OpenCollective</a>. We would also like to offer a huge shoutout and our gratitude to our trusted partners at Z Wave Development, BrieBug, Oasis Digital, and AngularFirebase along with Lukas Ruebbelke, Thomas Burleson, and Joshua Wiens.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5fc30bed260b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ngrx/announcing-the-release-of-ngrx-6-new-projects-and-looking-ahead-5fc30bed260b">Announcing the Release of NgRx 6, New Projects, and Looking Ahead</a> was originally published in <a href="https://medium.com/ngrx">@ngrx</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introducing @ngrx/entity]]></title>
            <link>https://medium.com/ngrx/introducing-ngrx-entity-598176456e15?source=rss-d6ba4dcb6838------2</link>
            <guid isPermaLink="false">https://medium.com/p/598176456e15</guid>
            <category><![CDATA[ngrx]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[rxjs]]></category>
            <category><![CDATA[reactive-programming]]></category>
            <dc:creator><![CDATA[Mike Ryan]]></dc:creator>
            <pubDate>Thu, 19 Oct 2017 14:34:03 GMT</pubDate>
            <atom:updated>2017-10-19T14:34:03.305Z</atom:updated>
            <content:encoded><![CDATA[<p>One of the most consistent complaints about building apps with NgRx is the amount of boilerplate developers have to write. The challenge when trying to solve the boilerplate issue is that the required explicitness is essential to get the full benefits out of the architecture. We think that by developing targeted libraries we can help reduce some of this boilerplate while retaining all of the benefits that NgRx provides.</p><p>Today we are excited to announce the release of @ngrx/entity, the first such library from the NgRx team designed to reduce boilerplate. Its goal is to help developers write reducer functions that maintain collections of entities.</p><h4>How it Works</h4><p>@ngrx/entity lets you create <em>entity adapters</em> for different kinds of entities. Using an entity adapter, you can quickly write reducer operations and automatically generate selectors. Pulling from our <a href="https://ngrx.github.io/platform/example-app">example application</a>, let’s say we want to write an application that manages a collection of books. The interface for books looks like this:</p><pre>interface Book {<br>  id: string;<br>  title: string;<br>}</pre><p>The first step to writing a reducer that manages this collection is to create an entity adapter:</p><pre>import { createEntityAdapter } from &#39;@ngrx/entity&#39;;</pre><pre>const bookAdapter = createEntityAdapter&lt;Book&gt;();</pre><p>Next we need to declare the interface for our books state:</p><pre>import { EntityState } from &#39;@ngrx/entity&#39;;</pre><pre>export interface BookState extends EntityState&lt;Book&gt; { }</pre><p>The shape of EntityState looks like this:</p><pre>interface EntityState&lt;V&gt; {<br>  ids: string[];<br>  entities: { [id: string]: V };<br>}</pre><p>There are two primary reasons we maintain a list of ids and a dictionary of entities:</p><ol><li>We want to make looking up a specific entity really fast. If you wanted to just select one book from the store, using the entities dictionary is much faster than searching through an array</li><li>We also want to maintain the order of the list. This is especially important if you want to keep the list sorted!</li></ol><p>The shape of EntityState&lt;V&gt; meets both goals. It’s also extendable, so we can include other pertinent information in the collection of Books, such as the currently selected book.</p><p>Next we define some actions:</p><pre>import { Action } from &#39;@ngrx/store&#39;;</pre><pre>export enum BookActionTypes {<br>  ADD_ONE = &#39;[Books] Add One&#39;,<br>  UPDATE_ONE = &#39;[Books] Update One&#39;,<br>  DELETE_ONE = &#39;[Books] Delete One&#39;,<br>  GET_ALL = &#39;[Books] Get All&#39;<br>}</pre><pre>export class AddOne implements Action {<br>  readonly type = BookActionTypes.ADD_ONE;</pre><pre>  constructor(public book: BookModel) { }<br>}</pre><pre>export class UpdateOne implements Action {<br>  readonly type = BookActionTypes.UPDATE_ONE;</pre><pre>  constructor(<br>    public id: string,<br>    public changes: Partial&lt;BookModel&gt;,<br>  ) { }<br>}</pre><pre>export class DeleteOne implements Action {<br>  readonly type = BookActionTypes.DELETE_ONE;</pre><pre>  constructor(public id: string) { }<br>}</pre><pre>export class GetAll implements Action {<br>  readonly type = BookActionTypes.GET_ALL;</pre><pre>  constructor(public books: BookModel[]) { }<br>}</pre><pre>export type BookActions<br>  = GetOne<br>  | UpdateOne<br>  | DeleteOne<br>  | GetAll;</pre><p>Now we are ready to use the bookAdapter to create our book reducer:</p><pre>const initialState: BookState = bookAdapter.getInitialState();</pre><pre>export function bookReducer(<br>  state: BookState = initialState,<br>  action: BookActions,<br>): BookState {<br>  switch (action.type) {<br>    case BookActionTypes.ADD_ONE:<br>      return bookAdapter.addOne(action.book, state);</pre><pre>    case BookActionTypes.UPDATE_ONE:<br>      return bookAdapter.updateOne({<br>        id: action.id,<br>        changes: action.changes,<br>      }, state);</pre><pre>    case BookActionTypes.DELETE_ONE:<br>      return bookAdapter.deleteOne(action.id, state);</pre><pre>    case BookActionTypes.GET_ALL:<br>      return bookAdapter.addAll(action.books, state);</pre><pre>    default:<br>      return state;<br>  }<br>}</pre><p>The new piece of state can be registered in the Store using the newly created reducer. The last thing we need to do is generate selectors for working with this state:</p><pre>export const {<br>  selectIds,<br>  selectEntities,<br>  selectAll,<br>  selectTotal,<br>} = bookAdapter.getSelectors();</pre><p>So what boilerplate did we save?</p><ol><li>No longer have to explicitly declare all of the properties for the state interface</li><li>The implementation for adding, deleting, or updating entities in the state are all handled by the adapter.</li><li>The adapter generates a set of commonly used selectors for you.</li></ol><p>More documentation about Entity is available in the <a href="https://github.com/ngrx/platform/tree/master/docs/entity">NgRx GitHub repo</a> and usage in the <a href="https://github.com/ngrx/platform/tree/master/example-app">example application</a>.</p><h4>NgRx 4.1 Released</h4><p>In addition to releasing @ngrx/entity, we have also published v4.1.0 of Store, Effects, and Router Store that includes a number of new features and bug fixes. For more information on what is included <a href="https://github.com/ngrx/platform/blob/master/CHANGELOG.md">please check the changelog</a>.</p><h4>Help Support NgRx</h4><p>With NgRx 4 we announced the creation of our <a href="https://opencollective.com/ngrx">OpenCollective</a> where you can help support the development of NgRx. We are very thankful for the support received from our backers, sponsors and community. Entity is the first the library created as a result of those contributions. Entity is the first step in creating more libraries for the NgRx platform. Consider supporting these development efforts <a href="https://opencollective.com/ngrx">through the OpenCollective</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=598176456e15" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ngrx/introducing-ngrx-entity-598176456e15">Introducing @ngrx/entity</a> was originally published in <a href="https://medium.com/ngrx">@ngrx</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular 2 First App Post-Mortem]]></title>
            <link>https://medium.com/@MikeRyanDev/angular-2-first-app-post-mortem-b2b2b3618828?source=rss-d6ba4dcb6838------2</link>
            <guid isPermaLink="false">https://medium.com/p/b2b2b3618828</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[rxjs]]></category>
            <category><![CDATA[angularjs]]></category>
            <dc:creator><![CDATA[Mike Ryan]]></dc:creator>
            <pubDate>Tue, 19 Jan 2016 13:58:11 GMT</pubDate>
            <atom:updated>2016-01-19T21:40:03.174Z</atom:updated>
            <content:encoded><![CDATA[<p>I recently got the opportunity to help build a web app using Angular 2. I think the framework suffers from complexity, though Angular 2 is undeniably powerful. This post-mortem delves into my experiences building with the framework, good and bad.</p><p><a href="https://www.angular.io/">Angular 2</a></p><h4>Angular 2 + Reactive Programming = ❤</h4><p>I was already using RxJS pretty heavily in my Angular 1 apps with subjects in particular making for great messaging busses between our services. With Angular 2 promising first-class support for observables I was excited to fully embrace reactive programming throughout the app.</p><p><a href="https://github.com/reactivex/RxJS">ReactiveX/RxJS</a></p><p>I leveraged the <a href="https://facebook.github.io/flux/docs/overview.html">Flux architecture</a> powered by the i<a href="https://github.com/rackt/redux">mmensely popular Redux library</a>. For a cleaner integration with Angular 2’s injector and TypeScript’s type system, I wrote a class-based wrapper around Redux that exposes state changes using RxJS observables. Consumers can subscribe to these observables and use the Store class to dispatch state-changing actions. André Staltz has <a href="https://gist.github.com/staltz/868e7e9bc2a7b8c1f754">an excellent guide</a> on reactive programming, and if you want to learn more about how to use Redux with Angular 2 or RxJS I recommend these resources:</p><ul><li><a href="https://medium.com/p/1cf18af27e6e">Angular 2 — Introduction to Redux</a></li><li><a href="https://github.com/ngrx/store">ngrx/store</a></li></ul><p>Complimenting the reactive programming style is a powerful new Http service that functions as an observable-based wrapper around XmlHttpRequest. In addition, the new Router exposes route changes as an observable which I leveraged to keep route state synchronized with my Redux store. With everything wired up, I was able to get a thin Angular 2 wrapper around the Redux dev tools working letting me tap into the power of their <a href="https://www.youtube.com/watch?v=xsSnOQynTHs">time traveling debugger</a>, a privilege that React developers have had for some time.</p><p>One disappointing part of reactive programming with Angular 2 is that the framework uses traditional callbacks to handle events and listen for input changes. Setting up event listeners in templates and using the callbacks to push to subjects isn’t too hard to setup yourself, and even hooking into Angular 2’s OnChanges lifecycle hook to do something similar for input changes is reasonable. Still, if Angular 2 <a href="https://github.com/angular/angular/issues/5689">supported these patterns</a> it would make reactive programming with the framework more natural.</p><h4>The Async Pipe is Amazing</h4><p>Perhaps the best part of selecting RxJS+Redux was how easy it was to connect state changes to Angular 2’s change detection cycle, thanks mostly to the async pipe. Angular 2 pipes are most commonly seen in template expressions to handle data transformation. They are analogous to filters from Angular 1 or traditional Unix pipes. The async pipe can subscribe to observables or promises passed to it and emit their values directly in templates.</p><p><a href="https://angular.io/docs/ts/latest/api/common/AsyncPipe-class.html">Angular 2</a></p><p>Taking the classic todo app example, here is a code sample using ngrx/store and the async pipe:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0e2bcc33292d460d31818dcfeb246a07/href">https://medium.com/media/0e2bcc33292d460d31818dcfeb246a07/href</a></iframe><p>Calling the pipe async is a bit deceiving here because ngrx/store exposes state with a <a href="https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/subjects/behaviorsubject.md">BehaviorSubject</a>. This means that the async pipe receives the most recent value immediately and is then notified asynchronously of any future changes made to the todo list. While awesome, this still isn’t optimal because Angular 2 will continue to perform wasted change detection on our component.</p><p>Lifting from React best practices, I separated components into two categories: wrapper components that were responsible for connecting to the Redux store, and pure components that received state through input properties and emitted output through events. This coupled with Angular 2’s capability to alter the change detection strategy for components resulted in change detection that occurred when my Redux Store dispatched changes. Here’s the above example refactored to demonstrate:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/be5417725d892242cd5505d350afd8d0/href">https://medium.com/media/be5417725d892242cd5505d350afd8d0/href</a></iframe><p>By setting TodoList’s <a href="https://angular.io/docs/ts/latest/api/core/ChangeDetectionStrategy-enum.html">change detection strategy</a> to OnPush I am telling Angular 2 to perform change detection if the inputs of TodoList change, and because the inputs are bound to my Redux Store using an async pipe TodoList will only update if my Redux Store updates.</p><p>This alone is a big win for me. With little code I can build clean, performant, and reactive UIs using Angular 2.</p><h4>Dependency Injection is Vastly Improved</h4><p>One of Angular 1’s shortcomings is its string-based <a href="https://docs.angularjs.org/guide/di">dependency injection</a>. It requires strict conventions to prevent naming collisions and special build tools to keep code minification safe. Thankfully in Angular 2 dependency injection has been vastly improved to overcome these flaws.</p><p>The first big change Angular 1 developers will notice is that DI now uses tokens instead of strings. You can still use strings for your provider tokens, however binding to types is the preferred way to go:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d30895ad44f951ffe6c99a30eaa6c9aa/href">https://medium.com/media/d30895ad44f951ffe6c99a30eaa6c9aa/href</a></iframe><p>With emitDecoratorMetadata turned on in the TypeScript compiler, the typings on class constructors is emitted in the class’s metadata. Angular 2 uses this type information to wire up dependency injection automatically, a capability typically reserved for languages with real reflection APIs.</p><p>The new injector is also hierarchical. Angular 2 creates a new child injector for each component it compiles, resulting in an injection hierarchy that matches the component hierarchy. This helps prevent global collisions and allows developers to write well-encapsulated components that declare their required providers as part of the component configuration.</p><p>One major downside of the injector isn’t so much in the injector itself but in how little type information is emitted by TypeScript during compilation. TypeScript interfaces and generic types lack a JavaScript counterpart resulting in the loss of runtime type information available to the Angular 2 injector.</p><p>Take a look at this TypeScript code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/78e08b92efa932e5a2946063f6642468/href">https://medium.com/media/78e08b92efa932e5a2946063f6642468/href</a></iframe><p>Using TypeScript’s experimental Reflect API, I expected the parameter type metadata emitted for MyService to look like:</p><pre>[[ ILights ], [ Camera&lt;string&gt; ], [ Action[] ]</pre><p>but instead I got:</p><pre>[[ Object ], [ Camera ], [ Array ]]</pre><p>The TypeScript compiler translated my ILights interface into the generic Object type, lost the precision of the generic type for my Camera class, and reduced my Action[] array signature down to just Array. This loss in type fidelity limits what kind of types I was able to actually use with Angular 2 providers.</p><p>Another major shortcoming of the type system is that sometimes the community type definitions for a library mistakenly declare types when they really mean to declare interfaces. For instance, when building my RxJS wrapper around Redux I wanted to provide Redux’s Store class using a factory:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9d6a47885d5a0b94e6a19ba6e62310b1/href">https://medium.com/media/9d6a47885d5a0b94e6a19ba6e62310b1/href</a></iframe><p>While that would appear to be valid, Reducer is actually just an interface and lacks a JavaScript equivalent. Thankfully TypeScript is smart enough to catch this and throw a warning when interface is used this way:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/448/1*okrU8aViZPYiCfrBB1A0Hg.png" /></figure><p>I refactored the code to provide Reducer using a string token:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e0ba4cd0671ff748b3ae282fecbe3f49/href">https://medium.com/media/e0ba4cd0671ff748b3ae282fecbe3f49/href</a></iframe><p>The above code compiles without issue but does not work. This is because the community typings for Redux declare Store as an exported class though Redux has no such export. This results in Store being undefined at runtime. I had to refactor the code again to provide both Reducer and Store using string tokens instead of types.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3828a83267bfb2f6f8b88ad89918d6c7/href">https://medium.com/media/3828a83267bfb2f6f8b88ad89918d6c7/href</a></iframe><p>Compounding my frustration was how difficult it was to debug this issue. TypeScript has no way of knowing that the type definition files don’t match the actual library. When I tried to register a provider for the Store class Angular 2 threw a comically cryptic error “Token must be defined!” and “TypeError: injector is undefined.” I eventually isolated the issue by comparing the named exports in Redux to the type definition file.</p><p>This was not a great experience and I can foresee this causing other developers some trouble when they try wiring up their favorite libraries into the injector using community written type definition files. It also seems unlikely that TypeScript will provide <a href="https://github.com/Microsoft/TypeScript/issues/3015">higher fidelity runtime types</a> in the future, potentially leaving Angular 2’s DI slightly crippled for some time to come.</p><h4>The New Router is Promising</h4><p>Angular 2 ships with a new router called the Component Router. It resembles something of a cross between react-router and Ember’s router. I generally found the Component Router to be “good enough,” though the routing requirements for my project were light.</p><p>For bigger projects the new router is missing some critical features that I will need like handling routing errors, easily redirecting missing routes to 404 pages, and resolving data before entering a route. I was able handle 404s by adding asterisk routes in all route configs, pointing these asterisk routes a 404 component. I was also able to temporarily solve data resolution by abusing the router’s @CanActivate decorator to execute async requests before entering routes.</p><p>One solution to these problems that I’ve seen other developers have some success with is to sub-class the router’s RouterOutlet component and manually enhance the router lifecycle hooks with new features. While this may end up being the preferred solution, for a framework that claims to prefer composition over inheritance, having to resort to sub-classing framework components does not feel like a particularly well thought out strategy.</p><p>I am hoping to see more routing alternatives as the framework nears release. Excitingly, there are already early proof-of-concepts of <a href="http://plnkr.co/edit/PF69BVa1WnUYZKkURgMm?p=info">ui-router</a> for Angular 2.</p><h4>ES5, ES2015, or TypeScript?</h4><p>I found the ES5 syntax for Angular 2 to be painful to use and the docs for vanilla ES2015 are nonexistent. Save yourself some effort and just use TypeScript (or Dart, if you fancy). One major reason for this is that Angular 2 makes heavy use of decorators including parameter decorators which are currently absent from the ES2017 decorator proposal:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1db3f2d166d2ae57d86a093a8ed1e576/href">https://medium.com/media/1db3f2d166d2ae57d86a093a8ed1e576/href</a></iframe><p>While I was able to wire up the metadata myself, the lack of both docs and brevity made it an exercise in pain:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f82b3c83ac4b8481753e8de4668372b8/href">https://medium.com/media/f82b3c83ac4b8481753e8de4668372b8/href</a></iframe><p>I found it to be even more chaotic when writing it in ES5:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1dd04832a372b32f5e56778a62047530/href">https://medium.com/media/1dd04832a372b32f5e56778a62047530/href</a></iframe><p>The Angular 2 team is <a href="https://github.com/angular/angular/issues/5449">prioritizing documentation for ES5, TypeScript, and Dart</a>, asking developers who want to use ES2015/ES2016 to learn how to de-sugar TypeScript’s syntax themselves. While I can certainly understand this decision (most frameworks hardly get one language’s documentation right), this effectively disqualified writing Angular 2 apps in anything but TypeScript.</p><h4>Angular 2 is Heavy</h4><p>When I say Angular 2 is heavy I mean it in two different ways: Angular 2 is heavy in terms of complexity, and the Angular 2 payload is large.</p><p>A common complaint about Angular 1 was the steep learning curve and wide breadth of new terminology. I honestly do not think Angular 2 does much to address these concerns and in many cases I found Angular 2 to be more complex. The upside here is that unlike Angular 1 a lot of best practices are baked right into the framework making it much safer to work with than its predecessor.</p><p>A good example of more complex but safer is Angular 2’s controversial new templating language. While I’m not going to make assertions about its quality, I will say that while the new language is more complex in comparison to Angular 1, the new templating language results in more predictable code. Not being able to place an *ngIf and an *ngFor on the same element, for example, negates the need to handle directive priority that existed with Angular 1. It also forces the developer to be a lot more explicit about expected results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*N12EOpzaU_iMwQdqiTuodw.png" /><figcaption>Ugly but explicit, I prefer this to Angular 1’s templating language</figcaption></figure><p>With the new templating language I was actually able to read a component’s template and tell the difference between various attribute bindings. This was a particular sore point with Angular 1 templates and their magic attribute bindings. While it took some getting used to, I am more productive with this templating language than I was with Angular 1&#39;s.</p><p>In terms of actual size my small Angular 2 app with code splitting is significantly heavier on initial page load than a 30K+ LOC Angular 1 app I previous worked on. With whispers of an audacious plan to get simple Angular 2 apps down to 10KB by the end of the year, I’m anxious to see how much this improves in the coming months. In the short term the Angular 2 team will be providing tools to compile templates and resolve injector providers as part of the build step rather than performing these tasks at run time. This should reduce how much code is needed to send down to end users and make the app run faster.</p><h4>Angular 2 is Powerful and Complex</h4><p>Would I choose Angular 2 for projects where I would have previously chosen Angular 1? Absolutely! I feel overwhelmingly confident that the current Angular 2 experience is vastly superior to Angular 1. It still retains some of its predecessor’s killer features like a great Http client, solid testing story, and painless forms. These have always stood out as the bread and butter of Angular, and I’m glad they remain great in Angular 2.</p><p>The finished app is also pretty stable given that Angular 2 is in early beta. Many of the rough edges I encountered came from cryptic error messages, spotty documentation, and weird tooling edge cases. These will be improved over time as the framework continues to grow and mature.</p><p>Still there’s simply no denying it: Angular 2 is complex and has a steep learning curve. The development experience has its number of “gotchas”, but none too severe to warrant dismissing the framework outright. Plus, many of the shortcomings I have addressed are already being actively worked on.</p><p>Want to try out Angular 2? For now, proceed with optimistic caution.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b2b2b3618828" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>