<?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 Erik Slack on Medium]]></title>
        <description><![CDATA[Stories by Erik Slack on Medium]]></description>
        <link>https://medium.com/@erikslack?source=rss-2d5528b3ead6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*lmCfG2rwqCWlYjhTqpiY4w.png</url>
            <title>Stories by Erik Slack on Medium</title>
            <link>https://medium.com/@erikslack?source=rss-2d5528b3ead6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 09:58:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@erikslack/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[Jenga Debugging]]></title>
            <link>https://medium.com/ngconf/jenga-debugging-c6ee4ce5e996?source=rss-2d5528b3ead6------2</link>
            <guid isPermaLink="false">https://medium.com/p/c6ee4ce5e996</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[thinking-outside-the-box]]></category>
            <category><![CDATA[collaboration]]></category>
            <category><![CDATA[debugging]]></category>
            <dc:creator><![CDATA[Erik Slack]]></dc:creator>
            <pubDate>Thu, 28 Sep 2023 00:46:27 GMT</pubDate>
            <atom:updated>2023-09-28T12:59:12.221Z</atom:updated>
            <content:encoded><![CDATA[<p>Jenga Debugging</p><figure><img alt="A Jenga tower with some pieces already relocated." src="https://cdn-images-1.medium.com/max/1024/0*VuWHwmV5l4K7dAC5" /><figcaption>Photo by <a href="https://unsplash.com/@imlst?utm_source=medium&amp;utm_medium=referral">Valery Fedotov</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Have you ever played Jenga? It’s a child’s game, that’s still actually pretty enjoyable as an adult. It’s how some of us learned a few basics of engineering and physics before we could even sing the alphabet. I’m going to tell you about an unorthodox way of debugging applications that I’ve been perfecting for years that I call Jenga Debugging. By using this method for debugging I’ve saved countless hours I would’ve spent chasing red herrings and false leads and instead finding a fix that just works. It’s okay if this method doesn’t work for everyone, the diversity of minds is one of humanity’s greatest strengths! For anyone who — like me — often loses focus or has the mind wander, this method can turn that exact weakness into a strength.</p><p>The method is simple, yet unintuitive, but trust me it works.</p><p>First, learn the problematic functionality. Say aloud to yourself or your team member what your desired outcome is and reach a consensus. You can write it down if that helps, but you will need to be able to come back to it again and again for this method to work.</p><p>Second, determine what has been tried to solve the problem and what the outcome was. Repeat for each attempt made. Don’t forget to be kind! Write it down if you have to. Whiteboards or stickies — in the words of Tyler Joseph, “Some see a pen, I see a harpoon.”</p><p>This is the part of the method that gives Jenga Debugging its name: it’s step 3. You have a choice to either continue to iterate on the ideas already presented or come up with a new one. Step 3 assumes you brainstorm a new one the fly. Think of the problem as a Jenga tower and the wood blocks as the things you could try. In Jenga each player in the game must pull out a block from somewhere on the tower except the top and then place it on the top while not making any part of the tower fall down. Usually if you mess up the whole thing comes crashing down in a stressfully loud, yet satisfyingly dramatic collapse of wooden blocks. The trick to surviving to late game in Jenga is to remove only blocks which have the least amount of tension on them so if it’s removed then nothing shifts weight rapidly or drastically. With the analogy you want to come up with an idea, explore it for a few minutes and if it yields any new information that can help you more deeply understand the problem then continue following it for another few minutes. If it doesn’t yield helpful new information about either the problem or the solution, then you stop trying that solution and you return to the original problem.</p><p>Return to step 1. Re-state aloud the problem and the desired outcome. Skip then to step 3 and brainstorm another solution. Eventually one of the “Jenga blocks” will give way much easier than the rest did and you’ll find new information about either the problem or the solution coming very easily.</p><p>Here are the DON’T DOS of this method:</p><ul><li>Don’t spend an hour on just one idea, until you have performed step 3 at least 3 times — sometimes it will be over a dozen times. Consider several options and gather that critical information only trying those different options can give you. Eventually you will spend more time on one solution than the others and it will be that solution which seemed most likely to succeed based on the information you uncovered.</li><li>Don’t lose sight of either <strong>the problem</strong> or the <strong>desired outcome</strong>! Of course you shouldn’t get stuck in a cycle of only revisiting those 2 things and not brainstorming a solution. You have to pull a block on your turn or forfeit the game — just talking about the tower being taller gets you nowhere. Still you must keep revisiting your base objective and current reality after spending time examining a solution if it has so far failed to achieve progress. This is how you will avoid falling down the cliche rabbit hole.</li><li>Avoid deep dives into breakpoint debugging, logs, or one part of the code. I don’t mean you won’t use them, of course you will and often! Pulling a block can be setting breakpoints, reading logs, printing to console, but if you’re spending more than a few minutes on it then ideally you’ve already discovered a loose Jenga block that’s likely to reveal more information or completely solve the problem.</li><li>Don’t hijack the conversation and prevent your fellow debuggers from contributing. Jenga is playable solo, but it’s even more fun when played by others who understand the game! Seriously, different brains are some of your best resources when debugging. Allow others to form hypotheses and note them. This is also how you build confidence in others and form stronger working relationships and trust.</li></ul><p>Let me know what you think of Jenga Debugging in the comments and if you too benefit from a similar approach or something totally different. I would love to hear what works for other types of minds. You all have greatness and potential within you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c6ee4ce5e996" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ngconf/jenga-debugging-c6ee4ce5e996">Jenga Debugging</a> was originally published in <a href="https://medium.com/ngconf">ngconf</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Tech Equivalent of Leg Day]]></title>
            <link>https://medium.com/ngconf/the-tech-equivalent-of-leg-day-a6266070fc0c?source=rss-2d5528b3ead6------2</link>
            <guid isPermaLink="false">https://medium.com/p/a6266070fc0c</guid>
            <category><![CDATA[storytelling]]></category>
            <category><![CDATA[podcast]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[intelligence]]></category>
            <category><![CDATA[tech]]></category>
            <dc:creator><![CDATA[Erik Slack]]></dc:creator>
            <pubDate>Tue, 21 Dec 2021 17:38:00 GMT</pubDate>
            <atom:updated>2022-02-08T17:37:15.326Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DMElXuyCiZt63OQCCPrVlA.jpeg" /></figure><h4>Don’t Skip the Angular Experience Podcast <a href="https://twitter.com/NgXP_Show">@NgXP_Show</a></h4><p>You ever heard the phrase, “Don’t skip leg day” and thought yeah, I really shouldn’t skip leg day? I’m referring to the day of the week when you focus on strengthening your many leg muscles through vigorous and often-times grueling exercise. Why do people skip leg day? Because our ideal body images are usually more focused on sculpting our upper bodies and trimming unwanted fat.</p><p>I’m really not an athletic person, yet I still try to keep healthy by eating right and exercising regularly. So please join me in pondering this short analogy for what Medium tells me is approximately 4 minutes of reading.</p><h3>Listening to NgXP is Like Exercising Your Legs</h3><p>If you skip leg day yet continue to work out your upper body and your core, you’ll have a weak foundation to stand upon. <strong>Your legs are like your tech-adjacent intelligence</strong>, and not just the soft skills — though those are crucial too! What I mean by tech-adjacent intelligence is the knowledge and abilities that some people at work have that make them excel in their career when paired with — or even in the absence of — shear technical intelligence.</p><p>Technical intelligence includes skills and knowledge that make you better at completing the technical tasks you accomplish on a daily basis. For some, that’s the code you write or the clusters you configure. If you’re like me, it might be all of the planning and strategy work you do to help advance the company’s goals. Sometimes it feels like an ocean of confluence/quip/word documents paired with a sky full of Jira tickets.</p><p>Either way, focusing on technical intelligence alone is a recipe for a mediocre career boost at best. Sadly, it’s often not until decades into your chosen career where you discover that fact. I’m a software engineer by trade, and I see a ton of value in letting all of you readers in on a little secret: your technical savvy can take you far, but it can only take you <em>so far</em>.</p><p><strong>I repeat: technical savvy will only get you so far!</strong></p><p>Technical-adjacent Intelligence is a handy little term encompassing the things that don’t get talked about and taught but are just as crucial to your career. Why doesn’t it get talked about? I honestly don’t think most folks are trying to keep it secret — though there may be some of that going around. I think it’s primarily because this kind of intelligence can’t be grokked in the same way as the technical skills you’ve been cultivating your entire career. These skills are only learned through story-telling by people who’ve been there before you. The stories of powerful and experienced individuals are the curriculum for greater success.</p><p>The main obstacle for you hearing these stories? It’s good ole Father Time! Highly successful individuals don’t have time to go sharing their stories with you all the time. Besides that, there is a serious lack of motivation for them to do so. There are, however, some generous thought leaders who have a lot they want to share with the each of us, yet due to time constraints, they must resolve to mentor us <em>at scale</em>.</p><p>What do I mean by mentoring at scale? It’s pretty straightforward actually! I can mentor one person at a time with the amount of free time remaining to me. However, it usually takes several months, or even years, to successfully mentor someone on how to become a software developer. So successful mentors for <em>many people</em> find ways to help a lot of people at once. The ways that they do this are through social media, videos, audio, and text such as this article. Not to say that I’m a successful thought leader, though I have successfully mentored people on a 1-on-1 basis several times. I have also taught people at scale before.</p><p>Here’s the deal, I’m offering free mentorship at scale here and I’m not doing it alone. I’ve recently launched a new podcast with my Co-Producer <a href="https://twitter.com/JediBravery">Brooke Avery</a>! We are providing a platform for renowned voices from the Angular Community to mentor us all at scale. We ask questions that go well beyond the technical and help you understand these figures in new and much more personal ways. There are a thousand and one podcasts that attempt to teach you the technical skills and knowledge to be successful at your job. We are the first podcast in the Angular Community to focus 100% on the secrets beyond the technical, the technical-adjacent intelligence.</p><p>Our guests have included <a href="https://twitter.com/John_Papa">John Papa</a>, <a href="https://twitter.com/DeborahKurata">Deborah Kurata</a>, <a href="https://twitter.com/jeffbcross">Jeff Cross</a>, <a href="https://twitter.com/samjulien">Sam Julien</a>, <a href="https://twitter.com/AlyssaNicoll">Alyssa Nicoll</a>, several members of the Angular team past and present and so many more. We don’t restrict ourselves to interviewing just the giants in the Angular Community, we also invite lesser-known guests and rising stars. Brooke and I are the embarrassingly unknown engineers who interview everyone we think has a powerful message or story you might want to hear or need to hear — even if you don’t realize it yet!</p><p>Subscribe to us on <a href="https://open.spotify.com/show/75JA1T8G5KYXZ18rTpFLUm">Spotify</a>, <a href="https://podcasts.apple.com/us/podcast/angular-experience/id1576779576?uo=4">Apple Podcasts</a>, <a href="https://www.audible.com/pd/Podcast/B08K54KN9X?qid=1629938438&amp;sr=1-1&amp;ref=a_search_c3_lProduct_1_1&amp;pf_rd_p=83218cca-c308-412f-bfcf-90198b687a2f&amp;pf_rd_r=YW6NH4F65G7E2PBBXFDA">Audible</a>, <a href="https://podcasts.google.com/feed/aHR0cHM6Ly93d3cuc3ByZWFrZXIuY29tL3Nob3cvNDkyNTAzOS9lcGlzb2Rlcy9mZWVk">Google Podcasts</a> and more. Give us and our guests your attention and come see what you might be missing to give you that leg up in your career! Not sure if you can spare the time? Then don’t! Listen while you do your weekly chores. We drop a new episode every single Monday.</p><p>Now that you’ve read this article and learned a thing or two (or ten!), let’s kick things up another notch!</p><p>Take your skills to a whole new level by joining us in person for the world’s first MAJOR Angular conference in over 2 years! Not only will You be hearing from some of the industry’s foremost experts in Angular (including the Angular team themselves!), but you’ll also get access to:</p><ul><li>Expert panels and Q&amp;A sessions with the speakers</li><li>A friendly Hallway Track where you can network with 1,500 of your fellow Angular developers, sponsors, and speakers alike.</li><li>Hands-on workshops</li><li>Games, prizes, live entertainment, and be able to engage with them and a party you’ll never forget</li></ul><p>We’ll see you there this August 29th-Sept 2nd, 2022. Online-only tickets are available as well.</p><p><a href="https://2022.ng-conf.org/">https://2022.ng-conf.org/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a6266070fc0c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ngconf/the-tech-equivalent-of-leg-day-a6266070fc0c">The Tech Equivalent of Leg Day</a> was originally published in <a href="https://medium.com/ngconf">ngconf</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lazy-Load Your Angular Components Whenever You Want]]></title>
            <link>https://medium.com/ngconf/lazy-load-your-angular-components-whenever-you-want-e9dd190ad505?source=rss-2d5528b3ead6------2</link>
            <guid isPermaLink="false">https://medium.com/p/e9dd190ad505</guid>
            <category><![CDATA[preloading]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[dialog]]></category>
            <category><![CDATA[angular-material]]></category>
            <category><![CDATA[lazy-loading]]></category>
            <dc:creator><![CDATA[Erik Slack]]></dc:creator>
            <pubDate>Wed, 07 Jul 2021 15:03:09 GMT</pubDate>
            <atom:updated>2022-09-20T19:11:57.288Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LNmzN354-3BHtWCB38ARAA.png" /></figure><p>Angular 10 included an exciting feature: the ability to lazy-load components at will. This enables us to develop applications where any components that don’t need to be loaded before showing the user the screen can be loaded when they are needing to be displayed. In the past, you would load all of your dialog components, slide-out-panels, and any other component which might not be shown until some user interaction — plus each of their dependencies — with the module that contained the route you were on. After reading this article, you’ll be able to lazy-load components at will.</p><h3>What’s the Point?</h3><p>It might seem innocuous to eagerly-load — what we usually do — all of your components that don’t need to be shown until some event/user-interaction. But, have you thought about those components’ dependencies? If you don’t have to load those components when the routed module gets loaded, then you won’t need the declarations, providers, modules, or anything else needed to support those components. This also means you’ll have smaller and more isolated components to test.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ouV_EwvpHg45I1bGgc5ipw.png" /></figure><p>So with this technique, you’ll get smaller bundle sizes and more control over what gets loaded and when it gets loaded.</p><h3>How It’s Done</h3><p>It’s important to understand that this technique can be used at any time to preload modules as you wish, but to teach this concept as simply as possible I’m going to focus on lazy-loading a dialog — aka modal — for inspecting a user’s details. This dialog should pop up after the user clicks on a specific user in a list or table of users. I’ve used this skill for plenty of other use-cases too, so don’t fret that I chose users and user details for this example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CilwW3Zwg3C0cTyky_KLOQ.png" /></figure><h4>Step 1: Create Your Dialog Component as Usual</h4><p>For this use case, we want to display a dialog containing a detailed view of a user. The process using Angular Material dialogs only requires two steps:</p><ol><li>Create a new component for the body of the dialog.</li><li>Have some code in the class of the parent component triggering the opening of the dialog.</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4558d17bd2d96aa4b67ec2d1589bd505/href">https://medium.com/media/4558d17bd2d96aa4b67ec2d1589bd505/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/889f9dc6753fa0400668dbdd0c007a19/href">https://medium.com/media/889f9dc6753fa0400668dbdd0c007a19/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/1*D65m6-X11Kwzc_WMu7IM8g.png" /></figure><h4>Step 2: Add a Module to the Dialog Component</h4><p>Now let’s convert this component to one that can be lazy-loaded by adding a module to it. Normally we’ll have one class per file as is the best practice, but in this case, I will display them in a single file to show all that is required to accomplish lazy-loading a component.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f6391f3b32538b49ca3e984b38ad9c1d/href">https://medium.com/media/f6391f3b32538b49ca3e984b38ad9c1d/href</a></iframe><p>Something to note is that it’s <em>not a good idea</em> to import this component into any other module ever because then it will be eagerly-loaded in spite of your work to make it load lazily. So, I recommend never making this module class exportable so that it can’t be accidentally imported. That’s another reason why it’s sort of perfect to keep both the component and the module in the same file.</p><h4>Step 3: Asynchronously Import Component then Open Dialog</h4><p>The last step is to change the way we open our dialog. We can’t just open the dialog anymore, we have to wait for the UserDetailDialogComponent to be loaded before attempting to open our dialog.</p><p>First, add a class property that is set equal to your import statement for the dialog component that returns a promise containing the UserDetailDialogComponent reference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/1*L0WDDxZv_hvnX6tDHR--CQ.png" /></figure><p>Second, call .then on your property using the component as your parameter to the arrow function. The function body provides a loaded component that can be opened by the dialog provider.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cd30cdb8e2eea89ad2aa727a98e08e93/href">https://medium.com/media/cd30cdb8e2eea89ad2aa727a98e08e93/href</a></iframe><h3>Conclusion</h3><p>It only took two short steps after creating your dialog to make it lazy-loaded. No extra npm packages required.</p><p>It’s a powerful technique that could greatly decrease your bundle sizes especially if you use it for any parts of the view that don’t need to immediately appear when the page loads. You could load entirely different versions of the view for mobile than for desktop in case the user resizes the window. You could even use this technique to preload components and modules at will.</p><p>Feel free to let me know in the comments if you have any questions, enhancements, or fixes. I appreciate you for reading this and feel free to clap if you liked this article — you can go up to 50 if this helped you a ton! I check back from time to time to feel the love and make minor improvements.</p><h4>Next Steps</h4><figure><img alt="Angular Experience Podcast Logo, fox jumping down from A" src="https://cdn-images-1.medium.com/max/1024/1*PjBYp12Nixm4AVrW8VnpRw.png" /><figcaption>Angular Experience Podcast is for developers and all kinds of tech persons just like you!</figcaption></figure><p>You might’ve seen on my twitter that I’m a Co-Producer &amp; Co-Host of the Angular Experience Podcast. Sometimes we get so caught up in writing Angular code, that we don’t take as much time to level up the other super vital skills related to our jobs. The Angular Experience Podcast, aka NgXP, is a podcast for the Angular Community by the Angular Community and beyond. Brooke Avery and I are meeting with some of the heroes in our community to help empower you to succeed in your tech career and personal life.</p><p>Come check it out <a href="https://twitter.com/DevLifePodcast">@NgXP_Show on Twitter</a>. You can subscribe to our show on any of your favorite podcast platforms!</p><p>Now that you’ve read this article and learned a thing or two (or ten!), let’s kick things up another notch! <br>Take your skills to a whole new level by joining us in person for the world’s first MAJOR Angular conference in over 2 years! Not only will You be hearing from some of the industry’s foremost experts in Angular (including the Angular team themselves!), but you’ll also get access to:</p><ul><li>Expert panels and Q&amp;A sessions with the speakers</li><li>A friendly Hallway Track where you can network with 1,500 of your fellow Angular developers, sponsors, and speakers alike.</li><li>Hands-on workshops</li><li>Games, prizes, live entertainment, and be able to engage with them and a party you’ll never forget</li></ul><p>We’ll see you there this August 29th-Sept 2nd, 2022. Online-only tickets are available as well.<br><a href="https://2022.ng-conf.org/">https://2022.ng-conf.org/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e9dd190ad505" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ngconf/lazy-load-your-angular-components-whenever-you-want-e9dd190ad505">Lazy-Load Your Angular Components Whenever You Want</a> was originally published in <a href="https://medium.com/ngconf">ngconf</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Caching GET Requests in NgRx]]></title>
            <link>https://medium.com/ngconf/caching-get-requests-in-ngrx-46233d0d0291?source=rss-2d5528b3ead6------2</link>
            <guid isPermaLink="false">https://medium.com/p/46233d0d0291</guid>
            <category><![CDATA[request-network]]></category>
            <category><![CDATA[cost-savings]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[ngrx]]></category>
            <category><![CDATA[caching]]></category>
            <dc:creator><![CDATA[Erik Slack]]></dc:creator>
            <pubDate>Tue, 01 Jun 2021 20:40:38 GMT</pubDate>
            <atom:updated>2024-05-11T01:14:45.982Z</atom:updated>
            <content:encoded><![CDATA[<p>It’s no secret that I’m a big fan of the NgRx Store for Angular. I’m also an avid Firebase user, but the nugget of wisdom I’m about to share with you will be useful with any backend.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_0F8We8aRAV9RTUH2u80SA.png" /></figure><p>Let’s face it, many of the network requests you make to fetch data from a back-end don’t need to happen more than once. Caching can help with that. Caching is predominantly a back-end concern, but it’s also helpful on the front-end side of things if used for the right things.</p><p>In this article I’m going to show you how to set up a super simple network cache in your NgRx effects, enabling you to reduce the network traffic in your application down to only what’s absolutely necessary.</p><h4>What Is Caching?</h4><p>Caching is when you store the results of an operation away for future use. For the purposes of this article, front-end network caching is the process of storing http responses in memory so that if you need to get the exact same information again you can avoid fetching it from the back-end multiple times.</p><h3>The Benefits of Front-End Network Caching</h3><p>There are two primary benefits to caching the responses to your GET requests:</p><ol><li>Decrease your network traffic, server requests, and database reads. If you’re charged based on the usage of any of these things, this can save you or your company a non-trivial amount of money. Always try to build discreet systems!</li><li>Speed up your users’ experiences because you don’t have to wait for data from another server instead you’re getting the same data from the client’s own machine.</li></ol><p>Both of those are pretty sweet rewards for what’s won’t take you very long to implement.</p><h4>When to Cache Responses</h4><p>You <em>should cache your responses </em>if you care about lightning-fast responses to your requests. You’ll still have to fetch data once the old-fashioned way though, so manage your expectations accordingly. Another use case is when you need to reduce your data footprint on either your data server or your database. In Firebase and other serverless architectures, reads saved equals money saved.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/819/1*1FcOVT66CGGlmIydLZNPSQ.png" /><figcaption>Save your money so you can afford a new hamster!</figcaption></figure><h4>When NOT to Cache Responses</h4><p>You <em>should NOT cache your responses </em>if you are building something that has volatile data or data that changes often. By often I mean within an hour or so. You could still cache your responses in this case, but you’ll have to build a mechanism for expiration into your solution as well. It’s also worth noting that the way you do your pagination might also be a factor. I find caching more effective with standard pagination, but with infinite scroll strategies, you already don’t need to reload data. So is caching necessary? Only you would know for your project.</p><p>Another point I should bring up is that some applications don’t care too much about space-complexity and focus on optimizing time complexity. Caching might not be right for an app that cares a lot about every piece of memory it’s using. As you can imagine the cache can grow.</p><h4>Out-of-the-Box Solutions vs Custom</h4><p>Why build your own solution when perfectly good ones already exist with more features and documentation than you ever dreamed of maintaining for your custom solution? There are good reasons to go custom. In this case, the custom solution is good enough 90% of the time and it’s not a ton of code. But one caching library I know of is called <a href="https://github.com/ngneat/cashew">Cashew</a>. I played with it for a few minutes and decided that it would be easier to just make my own thing since I was using NgRx Effects. In the next section, I’ll tell you how to do that yourself.</p><h3>Setting Up a Simple Cache in an NgRx Effect</h3><p>You’re probably thinking by now, “Get to the goods already Erik!” If you were, then keep in mind that the other stuff is for people who need a bit more context and advice. This part is the main course of this meal though!</p><h4>Step 1: Get Started With NgRx Store and Effects!</h4><p>Teaching you how to get started with NgRx Store and Effects isn’t the purpose of this article, but here are some links to help you learn those if you still need to:</p><ul><li><a href="https://ngrx.io/guide/store">https://ngrx.io/guide/store</a></li><li><a href="https://ngrx.io/guide/effects">https://ngrx.io/guide/effects</a></li><li>I’m going to adapt a talk I gave at the <a href="http://angularcommunity.net/">Angular Community Meetup</a> on the basics of NgRx and managing state in a future article. I’ll link it here when it’s published.</li></ul><p>Before you move to the next step, you should have a fully-functioning flow of NgRx store and effects. Verify you can get data and display it in your view. Once that’s done move on ahead!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*yvoWLoEfvYVkfFQKVFL94g.png" /><figcaption>Even when using high-powered tools like NgRx you can still make cool improvements like caching!</figcaption></figure><h4>Step 2: You’ll Need a Map</h4><p>First, let’s make a simple map and a variable to hold the currentId we’ll be working with.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d4ba5594e72a95b2606ed438156a6634/href">https://medium.com/media/d4ba5594e72a95b2606ed438156a6634/href</a></iframe><h4>Step 3: Update Your Effect to Store Responses</h4><p>I’m going to move forward with the step of saving the response data to the cache. I don’t necessarily <em>have to</em> save the whole response, I could also just save the part of it that I care about. Consider what works best for your needs.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/28049dd6cf16588f214fc81321a98ed7/href">https://medium.com/media/28049dd6cf16588f214fc81321a98ed7/href</a></iframe><h4>Step 4: Update Your Effect to Check the Cache First</h4><p>Finally, we need to make the effect check to see if the serialized action exists as a key in the map before we call the backend for more data.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c5839a1e2301f64a3b1999a67becc57d/href">https://medium.com/media/c5839a1e2301f64a3b1999a67becc57d/href</a></iframe><p>That’s it! Now if you dispatch the same action to get data twice — or a thousand times — it’s only going to get the data once for as long as your session remains open.</p><h4>A Note on Persistent Caching</h4><p>I didn’t cover in this article how to set up expiration or persist your cache. I’ll write a future article on this subject. Feel free to write a comment if you want this follow-up article and it may serve to prod me into writing it faster.</p><h3>Conclusion</h3><p>Now every time after the first your user clicks to load something, it won’t load it again, but your NgRx state flow remains pure. You don’t have to put that cognitive burden on yourself and your colleagues to remember when to dispatch the action or not. Your app will always do it the same way <em>every time!</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*_3XIBdi5SyRBGYo8gwe9CQ.png" /><figcaption>Just a few easy steps and you’re done. Until the next level that is…</figcaption></figure><p>I’ve found this technique extremely helpful for UIs that include pagination or detailed-view-screens. For example, you have a list of users and you want to see the details about a specific user. It might take a second to load it the first time, but after that it’s instantaneous. Go you!</p><p>Now get out there and build something awesome. Then come tell me about it on Twitter at @erik_slack!</p><p>Now that you’ve read this article and learned a thing or two (or ten!), let’s kick things up another notch! <br>Take your skills to a whole new level by joining us in person for the world’s first MAJOR Angular conference in over 2 years! Not only will You be hearing from some of the industry’s foremost experts in Angular (including the Angular team themselves!), but you’ll also get access to:</p><ul><li>Expert panels and Q&amp;A sessions with the speakers</li><li>A friendly Hallway Track where you can network with 1,500 of your fellow Angular developers, sponsors, and speakers alike.</li><li>Hands-on workshops</li><li>Games, prizes, live entertainment, and be able to engage with them and a party you’ll never forget</li></ul><p>We’ll see you there this August 29th-Sept 2nd, 2022. Online-only tickets are available as well.<br><a href="https://2022.ng-conf.org/">https://2022.ng-conf.org/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=46233d0d0291" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ngconf/caching-get-requests-in-ngrx-46233d0d0291">Caching GET Requests in NgRx</a> was originally published in <a href="https://medium.com/ngconf">ngconf</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RxJS for Beginner Angular Developers- Part 2: Fundamentals]]></title>
            <link>https://medium.com/ngconf/rxjs-for-beginner-angular-developers-part-2-fundamentals-535b939378d5?source=rss-2d5528b3ead6------2</link>
            <guid isPermaLink="false">https://medium.com/p/535b939378d5</guid>
            <category><![CDATA[rxjs]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[observables]]></category>
            <category><![CDATA[beginner]]></category>
            <category><![CDATA[unsubscribe]]></category>
            <dc:creator><![CDATA[Erik Slack]]></dc:creator>
            <pubDate>Tue, 23 Mar 2021 20:41:26 GMT</pubDate>
            <atom:updated>2022-07-21T15:39:54.391Z</atom:updated>
            <content:encoded><![CDATA[<h3>RxJS for Beginner Angular Developers: Fundamentals</h3><p>This is the second part to a series on RxJS for Beginner Angular Developers. Click this <a href="https://medium.com/ngconf/rxjs-for-beginner-angular-developers-introduction-2d26ffa364af">link</a> to read part one which is an introduction to observables and why they’re important to learn how to use. The article you are now reading will teach you how observables are created, subscribed to, and operated on.</p><p>Just a note, you can watch a <a href="https://youtu.be/uQGl9x9VHgA">video re-imaging of this article by the author here</a>.</p><figure><img alt="RxJS for Beginner Angular Developers Part 2: Fundamentals by Erik Slack" src="https://cdn-images-1.medium.com/max/600/1*p_qwC5ch1N5vWV5LIORdLQ.png" /></figure><h3>Overview of Observables</h3><p>Let’s do a quick recap on what observables are and how we use them.</p><p>Observables are a collection of values over time that we use to contain data retrieved asynchronously. They serve as a complete replacement for promises in our web applications and provide more benefits on top of it.</p><p>Using observables helps you in the following ways:</p><ul><li>Your code becomes more reactive.</li><li>You can compose your observables in many useful ways.</li><li>They allow you to pass streams containing one or many pieces of data.</li><li>Use them without data if you want to send signals to other parts of your code, but don’t need to pass data.</li><li>You can subscribe to an observable in many different places at once.</li><li>You can terminate observables by completing them and you can unsubscribe from them.</li></ul><p>It’s important to remember that observables won’t do anything until you subscribe to them. I’ll show you how to subscribe to observables later in this article.</p><figure><img alt="beautiful field of green 4 leaf clover" src="https://cdn-images-1.medium.com/max/1024/0*JunptICb-wDqLU1l" /><figcaption>Photo by <a href="https://unsplash.com/@xiaomingyo?utm_source=medium&amp;utm_medium=referral">Yan Ming</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>4 Ways to Create Observables In Angular</h3><p>There are several ways to create observables in Angular:</p><ol><li>Using one of several features in Angular that generate observables.</li><li>Using a library that works with Angular.</li><li>Using an RxJS creation operator.</li><li>Using an RxJS subject.</li></ol><p>Let’s dive into each of these and see how to make use of these.</p><h4>Angular Features Generate Observables</h4><p>In the last article of this series we discussed how RxJS came about in Angular 2 and beyond. Thanks to those early adopters and pioneers of RxJS it has advanced and been improved in significant ways since then. When Angular needs to return most pieces of data it does so using Observables. Here’s an incomplete list of features that do this:</p><ul><li>HttpClient: GET, POST, DELETE, etc.</li><li>Routing: RouterEvents, Router, ActivatedRoute</li><li>Events: FromEvent, EventEmitters</li><li>Angular Material: Dialogs, various CDK features, etc.</li></ul><h4>Libraries That Work With Angular</h4><p>There are many third-party libraries available in the npm ecosystem for Angular development. Two really notable ones are NgRx for reactive, central state and Angular Fire, an SDK for working with Firebase. Both of these third-party libraries generate observables. Many other libraries also generate observables — after all that is the Angular way of doing asynchronous things and it’s also the Angular way of passing data around.</p><figure><img alt="Shows how to open a dialog with Angular Material." src="https://cdn-images-1.medium.com/max/746/1*_4qv-Kgn_ai7bfaaGTjDHw.png" /><figcaption>Angular Material Dialog .open() .afterClosed() returns an observable!</figcaption></figure><h4>RxJS Creation Operators</h4><p>Creation operators are functions that create observables with predefined behavior. You usually use these in conjunction with pipeable operators — the other kind of operators. One of the simplest being the of(myValue) operator which takes any value and turns it into an observable. We’ll talk more about both kinds of operators later in this article.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sdo1_Prqyi_4IBHih-uzgQ.gif" /></figure><h4>RxJS Subjects</h4><p>RxJS subjects are basically observables that have three extra methods: next(), error(), and complete(). You can create a subject like this:</p><figure><img alt="private ngUnsubscribe = new Subject()" src="https://cdn-images-1.medium.com/max/894/1*lEYzygpzyrFsadM_FfFsKA.png" /><figcaption>Creating a new subject is easy!</figcaption></figure><p>You can create an observable from a subject by calling .asObservable() on it.</p><p>This allows you to completely control what gets emitted in an observable stream, how you handle errors, and when that stream should terminate.</p><p>There are different kinds of subjects: Subjects, BehaviorSubjects, ReplaySubjects, and AsyncSubjects. More often than not, you’ll be using regular Subjects or BehaviorSubjects. The main difference between Subjects and BehaviorSubjects is that with BehaviorSubjects you always have a value contained in them. You create them with a value and anything that subscribes to that value will get the latest value stored in it.</p><figure><img alt="new BehaviorSubject(initialScreenSizes); screenSizeSubject.asObservable()" src="https://cdn-images-1.medium.com/max/1024/1*0pxa2SuzI2wHEC0v8_Ykng.png" /><figcaption>Subjects can generate an observable by using .asObservable()</figcaption></figure><p>With subjects you don’t have to have a value in it. Often times you’ll create subjects to send signals to subscribers, as opposed to passing data through them.</p><h3>Operators</h3><p>Now that you’ve learned how to create observables in RxJS, let’s discuss how to use operators to manipulate them in various ways.</p><p>There are two kinds of operators: creation operators and pipeable operators.</p><h4>Creation Operators Continued</h4><p>There are all kinds of creation operators. Remember, creation operators are functions that create observables with predefined behavior. Earlier in this article I gave you an example of one creation operator. Here’s another commonly-used creation operator called combineLatest().</p><p>CombineLatest Operator takes two or more observables and combines the latest values emitted by each into a single observable stream.</p><figure><img alt="combineLatest([this.campaigns$, this.notes$])" src="https://cdn-images-1.medium.com/max/891/1*SPqAGusACDvMFcSZgEhhZQ.png" /><figcaption>Use combineLatest to combine the streams of multiple observables.</figcaption></figure><p>Another super handy creation operator is fromEvent().</p><figure><img alt="fromEvent(document, ‘click’)" src="https://cdn-images-1.medium.com/max/866/1*BEi8mAUGhaC6_GiTC4vHfA.png" /><figcaption>Use fromEvent() to generate an observable from a DOM event listener.</figcaption></figure><p>To round out your basic knowledge of creation operators I have to introduce you to of(). Of Operator creates an observable out of any value.</p><figure><img alt="of(someValue)" src="https://cdn-images-1.medium.com/max/803/1*kNhCDW7hSuSY7v-gwasniQ.png" /><figcaption>Use of() to make observables of absolutely anything! That’s a neat party trick.</figcaption></figure><p>The main purpose of this operator is to make it easy to generate observables when you require one for use with a library. It’s also handy for unit testing logic that uses observables.</p><h4>Pipeable Operators</h4><p>There are all kinds of pipeable operators. Pipeable operators are functions that manipulate an existing observable stream somehow. To use one you must call .pipe() on an observable and then give it operators for arguments. Notice how multiple operators can be chained within the same pipe. It’s a very readable syntax for such a powerful technique!</p><figure><img alt="Shows how to use filter and take operators." src="https://cdn-images-1.medium.com/max/877/1*WyOfUCfaMP6VxR6L4WH13w.png" /><figcaption>Filter and take are being used together in this pipe.</figcaption></figure><p>The Filter Operator is a fantastically useful one that will filter out anything emitted that doesn’t cause the filter’s handler function to return true.</p><p>The Take Operator is primarily used for triggering logic downstream only once. It’s also helpful for automatically unsubscribing, which I’ll address later in this article.</p><p>There are many, many operators to cover, so for now I’m just going to explain these last two: Map Operator and SwitchMap Operator.</p><p>The Map Operator is your go-to for transforming your observable’s value to something different. If you want to run some calculations on some data in your observable every time it emits then Map is your operator. It’s used very much like the prototypical map method for arrays in JavaScript.</p><figure><img alt="Shows how to map an observable and then map the array value inside it." src="https://cdn-images-1.medium.com/max/812/1*GhNl7hK3Dz3p8Y5zPQ0wew.png" /><figcaption>Don’t confuse RxJS map operator for the array map method. Mapping an observable and mapping or filtering the array contained therein is a common use case.</figcaption></figure><p>The SwitchMap Operator should be your first choice of operators when you want to swap — mid-stream — what observable you’re listening to. This is a really common thing to do. There is a lot more to SwitchMap Operator, but this is the most common use case: I want to pay attention to some Observable A, and once I get the emission I want from it I want to suddenly watch this other Observable B. It could be a httpClient.get(this.myUrl) or it could be an observable you’ve created.</p><p>There are 3 other operators that are similar to SwitchMap Operator because they take in an observable and emit a different observable. They are MergeMap, ConcatMap, and ExhaustMap. In most cases you’ll want to default to SwitchMap, but each has important differences to consider in how they process the new/inner observables.</p><p>For the next article in this series, I will go into further detail on these four and I’ll also cover many other commonly-used operators in RxJS.</p><h3>Subscribing</h3><p>There’s no point in learning how to use observables and operators if you never learn how to subscribe to them! Remember that observables don’t do anything until they’re subscribed to.</p><p>Subscribing to an observable is the way to make logic happen every time the observable emits. If your observable emits one time like with a typical http request, then your logic in the subscribe’s callback function will trigger once. If your observable emits many times — like when you create an observable from a click event listener using fromEvent()— then that same logic in the subscribe method’s callback function will trigger every time the observable emits. In the example it would be every time the user clicks on something.</p><p>A common use case for subscribing to an observable is because you want to <em>unwrap </em>the value it contains. If you want to display the latest value emitted by an observable you have to subscribe to it.</p><figure><img alt="Shows subscribing to an observable in your component’s class." src="https://cdn-images-1.medium.com/max/935/1*KIa_oseVmbM_YmPyUoWdUA.png" /><figcaption>Subscribe to trigger some logic every time the observable emits.</figcaption></figure><p>A subscription is returned when you call .subscribe() on an observable. You can store that subscription in a variable if you want to, but it’s not necessary. The main reason to do that is if you wanted to call unsubscribe() on it to cancel your subscription. But there are better ways to handle unsubscribing.</p><p>The second way to subscribe to observables in Angular is by using the built-in Async Pipe. If you reference your observable in your HTML template then you can use a pipe with it to automatically subscribe to the observable and return the latest unwrapped<em> </em>value. Using Async Pipe is arguably the best way to get the value out of an observable.</p><figure><img alt="Shows using async pipe in template." src="https://cdn-images-1.medium.com/max/1015/1*X-yfSq34lP4h8SzZCDItJQ.png" /><figcaption>Async pipe is #1 way to unwrap observables’ values for templates.</figcaption></figure><p>You should generally use Async Pipe whenever you need the value of an observable to display in your templates and when you want to pass its value to a component via property binding.</p><figure><img alt="Character punches big blow-up clown and it rocks back and knocks him over." src="https://cdn-images-1.medium.com/max/500/1*A2b5ibCGcS1LRlZGpSzEwA.gif" /><figcaption>Ha ha ha.</figcaption></figure><p>When you’re first learning RxJS it’s extremely tempting to subscribe to all of your observables and set their values as second properties on the component class. <strong>Avoid doing this! </strong>It’s a code smell to manually subscribe to an observable in your class just so you can store the value of the observable in a property.</p><h4>Unsubscribing</h4><p>Subscribing allows us to get the values out of an observable, but it comes with a consequence. That consequence is memory leaks that we need to handle.</p><figure><img alt="Memory leaks in bright green and bright red." src="https://cdn-images-1.medium.com/max/506/1*zV_nlcTckvqAffUsFr75HA.png" /><figcaption>But that’s the point: we are aware and we eliminate all leaks.</figcaption></figure><p>If we subscribe, then we must also unsubscribe. The ability to cancel subscriptions is the gold nugget that Ben Lesh originally proposed made RxJS a better default for async than promises. In RxJS you can cancel, let me show you how.</p><p>First way: .unsubscribe() is the worst possible way to unsubscribe from your subscriptions. Technically it works. You can store references to all of your subscriptions and then manually call .unsubscribe() on all of them in your ngOnDestroy() component lifecycle hook. I used to do this before I learned more about the other much better options: Take Operator, TakeUntil Operator, and Async Pipe.</p><figure><img alt="Shows unsubscribing 5 times in the ngOnDestroy lifecycle hook." src="https://cdn-images-1.medium.com/max/862/0*Jrh_Z6TxoovDhBw6" /><figcaption>Very messy! This is why we don’t unsubscribe manually.</figcaption></figure><p>Async Pipe is fantastic for all of the reasons I mentioned in the above Subscribing section, but there’s one really cool feature of it that I intentionally left out. That feature is that it handles unsubscribing automatically, so you never have to.</p><figure><img alt="Shows how to use async pipe in your templates to unwrap observable value." src="https://cdn-images-1.medium.com/max/1024/1*C4XPyXO8pSqTLJ3l8zmUaQ.png" /><figcaption>Default to using the async pipe if you’re using an observable in your template.</figcaption></figure><p>The Take and TakeUntil Operators are more useful for those times when you want to trigger a piece of logic based on events sending data through your observable stream. Use take(1) when you want to unwrap the value of an observable and use it for some one-and-done logic.</p><figure><img alt="Shows how to use take(1) to get a value once from an observable stream." src="https://cdn-images-1.medium.com/max/1024/1*nTsCNQ7Tc4tvl8F-R7Zwzw.png" /><figcaption>For one-and-done subscriptions use take(1).</figcaption></figure><p>On the other hand, if you want to stay subscribed until the browser gets closed or the user navigates to a different page that doesn’t include your component anymore you should use takeUntil(this.unsubscribeAllSubject).</p><p>First, create a new subject in a class property called unsubscribeAllSubject or ngUnsubscribe — basically you should always name it consistently so you know what it is when you see it. Next, add ngOnDestroy() {} lifecycle hook to your component. Inside of its scope block call next and complete on your subject.</p><pre>ngOnDestroy() {<br>  this.unsubscribeAllSubject.next();<br>  this.unsubscribeAllSubject.complete();<br>}</pre><p>Finally, add a takeUntil(this.unsubscribeAllSubject) operator to your observable in a pipe before your subscribe to it.</p><figure><img alt="Shows how to use a subject and ngOnDestroy to terminate observables." src="https://cdn-images-1.medium.com/max/1024/1*qb-8F8lngzJAa6dtpU9K6A.png" /><figcaption>For long lived subscriptions use TakeUntil() with a subject.</figcaption></figure><p>Now when your component is destroyed it will automatically free up that memory for you.</p><h3>Conclusion</h3><p>Congratulations on making it this far! You now have all of the necessary knowledge to get dangerous with RxJS. You show now understand how to create, use, change, combine, and cancel observables.</p><h4>Next Steps</h4><p>RxJS is a big subject! There’s a lot more to learn beyond the fundamentals. One excellent source for further learning is the <a href="https://medium.com/ngconf">ngconf publication</a> where this article has been published. Subscribe and keep growing your skills!</p><h4>More Next Steps</h4><p>In that same video you can learn from another ngconf Champion, <a href="https://medium.com/@michaelglenmadsen">Michael Madsen</a>, about styling and triggering logic by responding to device sizes — without needing media queries — <a href="https://medium.com/ngconf/reactive-responsive-design-in-practice-bddaae0dec29">using RxRs</a>.</p><p>Both of these concepts require at least some knowledge of RxJS and can improve your software development with Angular.</p><h4>Thanks for reading!</h4><p>If you liked this article, please give me some claps — you can give 50 you know! That helps me celebrate my accomplishment of successfully teaching others how to do this really cool thing. You can also follow me on Twitter at <a href="https://twitter.com/erik_slack">@erik_slack</a>. I invite you to dm me if I spoke incorrectly or you see a way to improve this article. Thank you for reading and please share it and stay tuned for the following two articles in the series!</p><p>Now that you’ve read this article and learned a thing or two (or ten!), let’s kick things up another notch!</p><p>Take your skills to a whole new level by joining us in person for the world’s first MAJOR Angular conference in over 2 years! Not only will You be hearing from some of the industry’s foremost experts in Angular (including the Angular team themselves!), but you’ll also get access to:</p><ul><li>Expert panels and Q&amp;A sessions with the speakers</li><li>A friendly Hallway Track where you can network with 1,500 of your fellow Angular developers, sponsors, and speakers alike.</li><li>Hands-on workshops</li><li>Games, prizes, live entertainment, and be able to engage with them and a party you’ll never forget</li></ul><p>We’ll see you there this August 29th-Sept 2nd, 2022. Online-only tickets are available as well.<br><a href="https://2022.ng-conf.org/">https://2022.ng-conf.org/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=535b939378d5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ngconf/rxjs-for-beginner-angular-developers-part-2-fundamentals-535b939378d5">RxJS for Beginner Angular Developers- Part 2: Fundamentals</a> was originally published in <a href="https://medium.com/ngconf">ngconf</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RxJS for Beginner Angular Developers: Introduction]]></title>
            <link>https://medium.com/ngconf/rxjs-for-beginner-angular-developers-introduction-2d26ffa364af?source=rss-2d5528b3ead6------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d26ffa364af</guid>
            <category><![CDATA[beginner]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[async]]></category>
            <category><![CDATA[rxjs]]></category>
            <category><![CDATA[observables]]></category>
            <dc:creator><![CDATA[Erik Slack]]></dc:creator>
            <pubDate>Fri, 12 Feb 2021 07:49:28 GMT</pubDate>
            <atom:updated>2022-02-09T03:55:06.543Z</atom:updated>
            <content:encoded><![CDATA[<h3>RxJS for Beginner Angular Developers- Part 1: Introduction</h3><figure><img alt="RxJS for Beginner Angular Developers Part 1: Introduction by Erik Slack" src="https://cdn-images-1.medium.com/max/600/1*jo2ux7M6YA8_laocf3B4ug.png" /></figure><p>Angular is a star front-end development framework and it has been since 2014. With how rapidly and consistently Google’s Angular Team continues to release major updates, it doesn’t look like that’s going to change any time soon. See their <a href="https://angular.io/guide/roadmap">recently published roadmap</a> for more vision into the future of the Angular framework.</p><h4>How to learn Angular</h4><p>There are many effective ways of learning new software development skills and concepts. Online learning subscriptions such as <a href="https://thinkster.io/">Thinkster.io</a> are one good way. Another great way is to buy a course from a famous Angular instructor like <a href="https://medium.com/u/410e2ec02d13">Deborah Kurata</a>. Joining a meetup like <a href="https://www.meetup.com/AngularUtah/">this one</a> is another fantastic way to not only learn, but become a part of the Angular community. Some people just buy a book on the subject from a respected publisher and read the thing — that doesn’t work for me personally. It’s much more exciting to attend — physically or virtually — a conference such as <a href="https://www.2021.ng-conf.org/">ng-conf</a>. All of these can be good ways to learn Angular.</p><figure><img alt="Gif animation of an old man writing “Dear Brynn…Please help Brandon…” in the style of an old pc adventure game. A jester is peeping at him through the window." src="https://cdn-images-1.medium.com/max/324/1*ZQNElVFmK0VGJqHTVU1o-A.gif" /><figcaption>Don’t let the jesters get you down, someone is always hoping for you to succeed!</figcaption></figure><p>If you’re like me then maybe what you want is a series of articles on the topic that you skim over quickly. And again if you’re like me then it doesn’t hurt if there are a bunch of gifs from your favorite classic video games sprinkled throughout. That’s exactly what you can expect from this series.</p><p>This is part 1 of a 3 part series on RxJS for beginners. You won’t be a pro at RxJS after reading this series, but you’ll have an excellent foundation that will help you start using RxJS in your everyday Angular development.</p><h3>What is RxJS?</h3><p>It’s distracting when someone teaches you a new thing without first defining what that thing is. <a href="https://rxjs-dev.firebaseapp.com/">RxJS</a> stands for <a href="http://reactivex.io/">Reactive Extensions</a> for JavaScript. It’s a library for composing asynchronous and event-based programs by using observable sequences. It provides one core type: the <strong>Observable</strong> and three satellite types: <strong>Observer</strong>, <strong>Scheduler</strong>, and <strong>Subject</strong>. RxJS also provides over 100 operators inspired by Array extras — for example, map, filter, reduce, every, and more — to allow handling asynchronous events as collections.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/100/1*b_CokII2C2_7-FagtSfrQA.png" /><figcaption>RxJS Logo</figcaption></figure><p>Now there’s another big distraction! By defining RxJS for you, I’ve introduced a ton of loaded concepts that you might not understand yet. That’s okay if you don’t understand them yet! This series of articles is dedicated to people who might not understand all of those concepts yet, and I’m about to explain them to you. I’m not going to explain computer science basics such as libraries or arrays and collections. Before you read this article you will need to know at least that much.</p><h4>What Are Asynchronous Programs?</h4><p>Web applications have changed a ton over the years from being simple static pages to animated monstrosities to server-side rendered screen-dumps, to asynchronous single-page applications. There are hundreds of minor steps and innovations in between and even after those big steps, but I’d say we’re still in the era of the single page application. Heretofore I will refer to them as SPAs.</p><p>Old-fashioned websites required refreshing of the entire page in order to go to another page — even if a lot of the pieces of that web page remained the same such as the sidebar, navigation bar, or footer section. These were mainly collections of files just moved onto a server where each page was just a static thing and you had links that moved you between them. That sucked because you had to wait for things to load every time and the screen would constantly repaint the entire thing even in situations where everything should look exactly the same. What saved us from this pain was <a href="https://www.w3schools.com/js/js_ajax_intro.asp">AJAX</a>.</p><figure><img alt="Hoagie is one of the protagonists of Day of the Tentacle and he is surfing on a hi-tech port-o-potty through time." src="https://cdn-images-1.medium.com/max/768/1*JnlBKQZPMaTHA_T7ZDC1lg.gif" /><figcaption>AJAX to the rescue!</figcaption></figure><p>AJAX — <strong>A</strong>synchronous <strong>J</strong>avaScript <strong>A</strong>nd <strong>X</strong>ML — was every developer’s dream because you can:</p><ul><li>Read data from a web server — after the page has loaded</li><li>Update a web page without reloading the page</li><li>Send data to a web server — in the background</li></ul><p>It’s not a programming language, just a method of doing the above things using a combination of browsers’ built-in <a href="https://www.w3schools.com/js/js_ajax_http.asp">XMLHttpRequest</a> object and JavaScript + <a href="https://www.w3schools.com/js/js_htmldom.asp">HTML DOM</a>—if you need to dynamically change something on the page visually.</p><p>This concept became the foundation of the SPA which has allowed endlessly more powerful applications to be built for the Internet. So what is asynchronous? The answer is any logic that isn’t done by the application synchronously. That isn’t a fulfilling answer though, so let me break it down further.</p><p>To display useful data to your user on their screen, you first need to have that data in your application. If you need data that your application doesn’t have hard-coded into it, then you’ll have to get that data from somewhere, usually a server on the internet somewhere. To get that data you’re going to have to make an HttpRequest to that server asking for it. The thing is, it’s impossible to know exactly how long it will take before that server will deliver your data to your application. Therefore it took an indefinite amount of time to accomplish that piece of logic giving you the data you asked for. The response didn’t come synchronously — or line after line of code — instead it came whenever it came. Usually, you’ve written some code prepared to do something with that data upon receipt. That’s why it’s called asynchronous.</p><h4>What Are Event-based Programs?</h4><p>The paradigm of <a href="https://en.wikipedia.org/wiki/Event-driven_programming">event-driven programming</a> is a pretty simple concept. You build your program so that it reacts to user actions — such as mouse clicks, key presses, and voice-activation — sensor outputs, or messages containing data from other programs — including programs running on other servers. In Angular, all of your logic is based on such events. So it makes perfect sense that Angular decided to include RxJS as a core library, because RxJS is about making it easy to react to events.</p><p>Even though RxJS is requisite for the Angular framework, some developers opt into not using it more than absolutely necessary. Part of the reason they do this is that we were reacting to events long before RxJS existed using callbacks and promises. Another part of the reason some developers don’t use RxJS much is that it adds a learning curve to your development and even though observables are here to stay, it’s not always easy to justify learning a new thing when you’re heads-down working on building new features and fixing bugs for your company. I’d argue that we constantly need to be improving our knowledge and skillsets — even if it’s on our own time — but even if it’s necessary, it’s not always easy to make time for it.</p><h4>What Is An Observable?</h4><p>An <a href="https://rxjs-dev.firebaseapp.com/guide/overview">observable</a> represents the idea of an invokable collection of future values or events. For now, I just want you to think of it as a tool in your programming for handling asynchronous logic. I’ll go into greater depth on observables in the next article.</p><h3>RxJS in Angular</h3><p>While RxJS isn’t only used in Angular, it is a proud member of the Angular ecosystem. But it might not have been if it weren’t for <a href="https://medium.com/u/da6839d28258">Ben Lesh</a>.</p><figure><img alt="Ben Lesh presenting at ng-conf 2018" src="https://cdn-images-1.medium.com/max/400/1*pshLZm-pYeC6FaQmL8lInQ.jpeg" /><figcaption>Ben Lesh presenting at ng-conf 2018</figcaption></figure><h4>A Brief History</h4><p>During the early, early days of Angular 2, a new hire named Ben Lesh that had recently come from working at Netflix shared his ideas around async with <a href="https://twitter.com/IgorMinar">Igor Minar</a> and <a href="https://twitter.com/mhevery">Misko Hevery</a>. He concluded that promises weren’t the ideal abstraction of async primarily because of a lack of sufficient handling of cancellation. Ben set up a meeting between those two and <a href="https://twitter.com/jhusain?lang=en">Jafar Husain</a>, the Cross-Team Technical Lead for the Netflix UIs.</p><p>At the time it also seemed to all of them that <a href="https://tc39.es/">TC 39</a> was going to be adopting observables. That didn’t happen, but it turned into a partnership between Angular and RxJS nonetheless. This information comes from an interview of Ben Lesh done by the team of the <a href="http://ng.show/">Angular Show Podcast</a> episode 30. The Angular Show Podcast is another excellent resource for learning about Angular and its community.</p><h4>Where is RxJS Today?</h4><p>The following features in Angular leverage Observables by default:</p><ul><li><strong>Routing </strong>emits parameters via a paramMap Observable</li><li><strong>FormControl </strong>emits a value via a valueChanges Observable</li><li><strong>HttpClient </strong>emits the response via an Observable</li><li><strong>Output/event-emitters</strong> generate Observables</li><li>Angular has a built-in <strong>Async pipe</strong> for automatically unwrapping observable-contained values in templates.</li></ul><figure><img alt="A bunch of well known company logos that use ReactiveX for their products." src="https://cdn-images-1.medium.com/max/727/1*f18o2zj1kJuqYhnci_Z-0Q.png" /><figcaption>There are many others + every company that uses Angular!</figcaption></figure><p>Here are some other really cool facts about RxJS today:</p><ul><li>RxJS became the cornerstone of state in Angular, for example NgRx.</li><li>The Angular Team embraced RxJS in much of the Angular ecosystem</li><li>RxJS is the #1 requested subject at ng-conf</li><li>20,000 other libraries depend on RxJS, and currently, it almost has more downloads than Angular and React combined times 2 at approximately <a href="https://www.npmjs.com/package/rxjs">23 million per week</a>.</li><li>An adaptation of Reactive Extensions is available for idiomatic Java, Scala, C#, C++, Clojure, Python, Groovy, JRuby, and other programming languages.</li></ul><h4>The Future of RxJS</h4><p>RxJS is Open-sourced Software which is marvelous because you can dig into the source code and see how it works. It also means that the community controls how RxJS will evolve, not just a single company. The problem with open-sourced software is that it’s practically impossible to predict when new versions will become available. That’s because the people working on it are all volunteers — as is the nature of OSS.</p><p>Want the future of RxJS to come sooner? Consider joining the team of people working on it by contributing to it on <a href="https://github.com/ReactiveX/rxjs">GitHub</a>.</p><h4>Next Major Version of RxJS</h4><figure><img alt="RxJs 6 was 93KB and RxJS 7 will be 57KB. That’s smaller!" src="https://cdn-images-1.medium.com/max/412/1*kJCEX-JC3v3DA3iJ4DZjLg.png" /><figcaption>Significantly smaller!</figcaption></figure><p>At the time of writing this article, RxJS version 7 is still being worked on. It will include the following changes and more:</p><ul><li>Better TypeScript typings</li><li>The toPromise operator is changing to firstValueFrom and lastValueFrom</li><li>RxJS is smaller</li><li>RxJS supports the latest TypeScript version: Typescript 4.1</li></ul><h3>In Conclusion</h3><p>If you’re still on the fence about using RxJS with your Angular applications then it might be because of the following concerns:</p><ol><li>Complexity — even for an experienced front-end developer it involves a new pattern and requires us to expand our training. We are busy and this seems like it will take valuable time.</li><li>Necessity — is it worth it to learn this? It seems like I can accomplish the same things using techniques I already understand like promises and async/await.</li><li>History — I’ve had difficulties with this concept in the past or I’ve had coworkers who over-complicated things using this tool.</li><li>Learning Curve — Is this going to make doing front-end harder than it needs to be? How are we going to train up beginners to do yet another complex thing?</li></ol><p>My response to these concerns is below.</p><p>As software engineers, we work and live in an environment that is ever-expanding. Staying current in technology is an absolute necessity in our chosen career field. Front-end work has rapidly and drastically evolved over the past decade. Many features of applications that were only possible in the back-end are now things the front-end has taken command of. There are good reasons for that.</p><p>Client machines are more capable of processing logic than ever before, so businesses can distribute a lot of the compute cost onto the end-users through powerful front-end systems. We are also living in an age where society at large is educated about computers and so while our user base is almost universal, so are the laws and best practices. We are evolving with them.</p><p>The answer is not to throw our hands out and push against the wheel of innovation. RxJS is undoubtedly an innovation. It’s powerful, it solves several problems that promises are ill-equipped to solving and they do it elegantly.</p><p>The learning curve is real. The burden is on those who are grounded in years of experience in software engineering to soften the learning curve by teaching and mentoring our juniors and our peers. The negative experiences I’ve seen in the past and those that I’ve heard stories about from colleagues are almost always the result of one or more of the following:</p><ul><li>a lack of adequate mentoring</li><li>a lack of sufficient standards</li><li>a lack of desire to embrace change or learn</li></ul><p>I know! I’ve been there. RxJS was hard for me at first too. It’s still hard for me sometimes when I’m solving really complicated problems. I’ve grown comfortable using RxJS for most of my async logic in Angular applications and so can you.</p><h4>Next In the Series: Fundamentals of RxJS</h4><p>In my <a href="https://medium.com/ngconf/rxjs-for-beginner-angular-developers-part-2-fundamentals-535b939378d5">next article in the series</a>, I’ll go over Observables, Operators, Subjects and all of the basics you need to know conceptually about RxJS.</p><p>I’ll come back and update the previous articles in the series with links as I publish them.</p><figure><img alt="Red, white, and blue cone-shaped flag with three circles on it waving in front of a sun rise. From Day of the Tentacle." src="https://cdn-images-1.medium.com/max/781/1*7f1UxbDPRQBt7qp80Ig5JQ.gif" /><figcaption>Soon you will have mastered RxJS, maybe even tomorrow.</figcaption></figure><h4>Thanks for reading!</h4><p>If you liked this article, please give me some claps — you can give 50 you know! That helps me celebrate my accomplishment of successfully teaching others how to do this really cool thing. You can also follow me on Twitter at <a href="https://twitter.com/erik_slack">@erik_slack</a>. I invite you to dm me if I spoke incorrectly or you see a way to improve this article. Thank you for reading and please share it and stay tuned for the following two articles in the series!</p><p>Now that you’ve read this article and learned a thing or two (or ten!), let’s kick things up another notch!</p><p>Take your skills to a whole new level by joining us in person for the world’s first MAJOR Angular conference in over 2 years! Not only will You be hearing from some of the industry’s foremost experts in Angular (including the Angular team themselves!), but you’ll also get access to:</p><ul><li>Expert panels and Q&amp;A sessions with the speakers</li><li>A friendly Hallway Track where you can network with 1,500 of your fellow Angular developers, sponsors, and speakers alike.</li><li>Hands-on workshops</li><li>Games, prizes, live entertainment, and be able to engage with them and a party you’ll never forget</li></ul><p>We’ll see you there this August 29th-Sept 2nd, 2022. Online-only tickets are available as well.</p><p><a href="https://2022.ng-conf.org/">https://2022.ng-conf.org/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d26ffa364af" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ngconf/rxjs-for-beginner-angular-developers-introduction-2d26ffa364af">RxJS for Beginner Angular Developers: Introduction</a> was originally published in <a href="https://medium.com/ngconf">ngconf</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Nest Lazy-Loaded Modules]]></title>
            <link>https://medium.com/ngconf/how-to-nest-lazy-loaded-modules-2d73a7881be?source=rss-2d5528b3ead6------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d73a7881be</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[routing]]></category>
            <category><![CDATA[beginner]]></category>
            <category><![CDATA[router]]></category>
            <category><![CDATA[nested-routes]]></category>
            <dc:creator><![CDATA[Erik Slack]]></dc:creator>
            <pubDate>Fri, 16 Oct 2020 15:36:59 GMT</pubDate>
            <atom:updated>2021-09-14T20:48:00.097Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="A nest with baby birds and one has its beak wide open. There is a blue rectangle with “How to Nest Lazy-Loaded Modules.”" src="https://cdn-images-1.medium.com/max/600/1*mYeNoNG91FtH3WELg2Z3IQ.png" /><figcaption>Photo by <a href="https://unsplash.com/@martysouthwell?utm_source=medium&amp;utm_medium=referral">Marty Southwell</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Lazy-loading modules and routing in Angular is a pretty well-covered and well-rehearsed topic. But lately I’ve noticed there’s an absence of great explanations for nested lazy-loading. I’m going to go briefly over this fairly simple topic. It is really simple, but it’s not at all straightforward.</p><h3>Introduction to Lazy-loaded Routes</h3><p>Angular is a very elegant and opinionated framework for Typescript. There are so many useful features built into it, one of which is routing. Routing is what simulates having multiple pages in a Single Page Application. Good routing is dynamic, flexible, and configurable. Angular routing is all of those and more. One of the ways it’s configurable is that you can lazy-load your components using a combination of routing and feature modules.</p><p>Feature modules allow you to separate code in a — what else? — modular way. The benefit is that you can load chunks of code when you need them as opposed to forcing your app to load everything all at once. This can significantly improve page load times and decrease coupling of components. You might say, “my two modules are both pretty small, so I might as well eagerly load them,” but in my experience everything tends to grow over time. It’s always best to lazy-load your routes. Besides, you’re not just lazy-loading the components <em>you</em> built, but also the dependencies of those components. The better question is why wouldn’t you lazy-load all of your routes?</p><p>One reason you might not want to do it is because then you’ve got to add an extra module file, but trust me when I tell you that’s a super cheap price to pay. I’m not saying you have to start all routes as lazy loaded modules though; you can easily convert normal routes to lazy-loaded routes at anytime. Let me show you how.</p><h3>How to Make a Lazy-loaded Route</h3><p>It’s super easy! Let me show you a regular route first and then I’ll transform it into a lazy-loaded route.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/38e4358ec64d6366797a18088f2f0b9a/href">https://medium.com/media/38e4358ec64d6366797a18088f2f0b9a/href</a></iframe><p>This route is eagerly loaded since all its dependencies are loaded in the module in which it is imported. It isn’t separating something into modules alone that makes it lazy-loaded. Here is the same route now lazy-loaded instead of eagerly loaded.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/90ec6fa1dc0ee960e3758a0f5ce094b0/href">https://medium.com/media/90ec6fa1dc0ee960e3758a0f5ce094b0/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/138e8f72cf63b441fd2c5b27ed7bdb6b/href">https://medium.com/media/138e8f72cf63b441fd2c5b27ed7bdb6b/href</a></iframe><p>This route is now lazy-loaded. Note that in this module we use the forChild() method instead of forRoot(). You must do this for any module that is meant to be lazy-loaded. Use forRoot() in the root module which is usually app.module.ts or the corresponding routing module.</p><p>The module, its components, and all of its dependencies will not load to the client until the user navigates to this route.</p><figure><img alt="Shows a lazy-loaded module appearing as a new chunk in the network tab after navigating to the home route." src="https://cdn-images-1.medium.com/max/986/1*nS1ztU5PU7j7iITmNUu3NA.png" /><figcaption>You can see the chunk of js loading in the network tab of the Chrome developer tools. It worked!</figcaption></figure><h3>How to Nest Lazy-Loaded Routes</h3><p>The previous stuff was more for beginners doing lazy-loaded routing for the first time. Now I’m going to explain the stuff that isn’t readily apparent when trying to nest routable modules.</p><p>I’ve built many applications that work better with large feature modules that contain multiple lazy-loaded child routes. So from my app.routing.ts file I lazy load these big modules with a path. Then in each large feature library, I’ll lazy-load a module for each of the components in that module. Remember that my goal is to lazy-load <em>all</em> routes. This requires you to nest routes.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bbae4e928882050f0380482edefd13b2/href">https://medium.com/media/bbae4e928882050f0380482edefd13b2/href</a></iframe><p>It looks really similar to the way I did it in the app.routing.ts file, but there are some key differences that aren’t readily apparent. The most important thing to keep in mind is how and when to use the <strong>pathMatch</strong> property.</p><figure><img alt="Animated GIF of old-school prince of persia jumping over spikes to hang onto a ledge by his finger tips." src="https://cdn-images-1.medium.com/max/500/0*ZsqMA6-5Vu-Cwhj3.gif" /><figcaption>Avoiding pitfalls like a boss.</figcaption></figure><h3>Pitfalls of pathMatch</h3><p>The property on a route called pathMatch is used to determine whether a route should match or not in two different ways. The default value is ‘prefix’ and this will match any route that includes it and can includes suffixes too. This is opposed to pathMatch: ‘full’ which will only match routes that <em>end</em> in this path. Did you have to reread that? It’s okay, it really isn’t super clear. Let me show you when to use each of these values for pathMatch<strong>.</strong></p><h4>Routes with pathMatch: ‘prefix’ (Default Value)</h4><p>If you don’t specify explicitly that a route should be pathMatch: ‘full’ then it will automatically be pathMatch: ‘prefix’, which results in the following behavior:</p><ul><li>This route is triggered whenever a child route matches the path of this route.</li><li>This route overrides other routes that include its path + suffix.</li></ul><h4>Routes with pathMatch: ‘full’</h4><p>Specifying pathMatch: ‘full’ results in the following behavior:</p><ul><li>This route will only be triggered if it doesn’t have a suffix after the path.</li></ul><h4>When to Use Each</h4><p>You’ll want to use pathMatch: ‘full’ in the following situations:</p><ul><li>When you want a route to redirect to another path using path: ‘’ aka empty route.</li><li>When you have a route with a route param that should use a different component than the route without the param. For example:</li></ul><pre>‘/accounts/:accountId’</pre><p>vs</p><pre>‘/accounts’</pre><p>You’ll want to use default pathMatch for every other situation.</p><p>Here’s a tip: if a route <strong>should</strong> match child routes — meaning you want to nest routes then you must have a base component for each parent route that contains a router outlet, i.e.</p><pre>&lt;router-outlet&gt;&lt;/router-outlet&gt;</pre><p>Your child routes won’t show up if you don’t have that element. If you make the misguided mistake of putting pathMatch: ‘full’ on that route then none of your child routes will work. Take it off immediately! Voila! It works now.</p><p>Hopefully, this helps save someone else a bit of confusion about nested routing.</p><h4>What’s next?</h4><p>Check out <a href="https://medium.com/ngconf/build-sell-apps-not-content-angular-with-flamelink-and-firebase-2604ed9a157b">this article I wrote</a> last about using Angular with Firebase and Flamelink to give you Firebase-powered CMS in your Angular application!</p><p>I also recommend that you scroll through the list of other articles published by ng-conf. <a href="https://medium.com/ngconf">Click here to read them all</a>!</p><figure><img alt="ngEnterprise logo" src="https://cdn-images-1.medium.com/max/100/1*xwWAmvrBLI7dOOnqgV02JA.png" /><figcaption>EnterpriseNG Logo</figcaption></figure><h4>I hope I see you at EnterpriseNG!</h4><p>EnterpriseNG is a two-day conference by the team that puts on ng-conf focused on Angular in the enterprise. I’ll be there — virtually of course. It’s taking place November 19th and 20th. Check it out at <a href="https://www.ng-conf.org/">ng-conf.org</a>.</p><figure><img alt="Animated GIF of skeletons dancing while a man plays bone-xylophone with bone drumsticks. From old-school Kings Quest game." src="https://cdn-images-1.medium.com/max/640/0*nV13f_8g-Nf7o0m3.gif" /><figcaption>All of us partying together next month at EnterpriseNG!</figcaption></figure><h4>Thank you for reading!</h4><p>If you liked this article, please give me some claps — you can give up to 50! That helps me celebrate my accomplishment of successfully teaching others how to do this thing. You can also follow me on twitter at @erik_slack. I invite you to dm me if you have any questions about my article. Thank you for reading it, please share!</p><h3>EnterpriseNG is coming November 4th &amp; 5th, 2021.</h3><p>Come hear top community speakers, experts, leaders, and the Angular team present for 2 stacked days on everything you need to make the most of Angular in your enterprise applications.<br>Topics will be focused on the following four areas:<br> • Monorepos<br> • Micro frontends<br> • Performance &amp; Scalability<br> • Maintainability &amp; Quality<br>Learn more here &gt;&gt; <a href="https://enterprise.ng-conf.org/">https://enterprise.ng-conf.org/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d73a7881be" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ngconf/how-to-nest-lazy-loaded-modules-2d73a7881be">How to Nest Lazy-Loaded Modules</a> was originally published in <a href="https://medium.com/ngconf">ngconf</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build & Sell Apps, Not Content — Angular with Flamelink and Firebase]]></title>
            <link>https://medium.com/ngconf/build-sell-apps-not-content-angular-with-flamelink-and-firebase-2604ed9a157b?source=rss-2d5528b3ead6------2</link>
            <guid isPermaLink="false">https://medium.com/p/2604ed9a157b</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[flamelink]]></category>
            <category><![CDATA[content]]></category>
            <category><![CDATA[headless-cms]]></category>
            <dc:creator><![CDATA[Erik Slack]]></dc:creator>
            <pubDate>Wed, 09 Sep 2020 15:00:22 GMT</pubDate>
            <atom:updated>2021-09-14T20:35:19.670Z</atom:updated>
            <content:encoded><![CDATA[<h3>Build &amp; Sell Apps, Not Content — Angular with Flamelink and Firebase</h3><p>The main draw of any CMS is that it lets authorized users customize content without having any knowledge of how to code. If someone knows how to use a text editor, then they should be able to create new content using the CMS. I’m going to teach you how to set up Firebase and add <a href="https://flamelink.io/">Flamelink</a> to your Angular application. You’ll have it up and running in short order!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ntbRYVOzk01e1e4NtwiZvQ.png" /></figure><h3>Old-School Content Management Solutions (CMS)</h3><p>Remember Drupal and Wordpress? I sure do! It used to be the bread and butter of my self-employment for about three years. I used to love Wordpress for the separation of concerns between building a website and generating that site’s content a website for someone from the generation of that website’s content. My slogan was, “We tailor the web to fit you!” and I ended up building some pretty fancy applications. I also educated clients on how to use Wordpress admin tools to create content.</p><p>Eventually, I began to dislike CMS platforms because of the constraints imposed by their frameworks and languages. I jumped on Angular asap and never looked back. To this day, I would never take on another Wordpress project, and don’t need to thanks to Flamelink and other headless CMS solutions.</p><figure><img alt="Kid wearing sunglasses is buried in sand up to his neck." src="https://cdn-images-1.medium.com/max/1024/0*_S_7NGAhGYNyquxL" /><figcaption>Photo by <a href="https://unsplash.com/@richardpennystan?utm_source=medium&amp;utm_medium=referral">Richard Pennystan</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Convert to Headless CMS and Don’t Ever Look Back</h3><p>Headless CMS decouples the experience of content creators/editors from the web application consuming the created data. Here’s a brief analogy; the people writing the news don’t have any effect on the platform that displays that news. In fact, multiple platforms could display the same news in different ways in infinite locations. Why should content be any different? The correct answer is it shouldn’t.</p><p>Headless CMS is the best direction to go for any modern project that has CMS needs. Two of excellent use cases for a headless CMS are:</p><ol><li>For your business’ clients — your clients need to generate and edit their own content and they do not know HTML or CSS. Or, you wish to separate the responsibility of developing an application from the grunt work of making the content.</li><li>For the enterprise employer — your company wants to update a site without waiting on developers. To avoid having full-fledged CMS tools which have to be upkept and maintained differently from their other applications, but still keep many of the same features like translations, scheduling, and roles.</li></ol><p>Headless CMS will never fully render the classical CMS obsolete, but if you’re a software developer and you already know how to build Angular applications — or any other frameworks/platform — then 99% of the time you should NOT use a classical CMS. You will have greater efficiency, liberty to choose your own tools, and capability for building discrete systems — something we don’t focus enough on sometimes — if you use a headless CMS to power the content of your applications.</p><figure><img alt="Flamelink logo on geometric field of orange." src="https://cdn-images-1.medium.com/max/1024/0*BkgZnvCs-oSUV-Ss.png" /></figure><h3>Enter Flamelink</h3><p>Flamelink is a content-centric headless CMS that seamlessly integrates Firebase. Full disclosure: I have not ever nor will I ever be compensated by Flamelink to say this next bit. Flamelink is my go-to choice for headless CMS and here’s why:</p><ul><li>simple to set up</li><li>zero headache to maintain</li><li>it’s easy to teach to non-techy people — no training necessary as it’s fairly self-explanatory.</li><li>it’s Firebase! Don’t get what I mean? I can get an Angular app running with hosting, analytics, database, and backend in just a couple of hours when I pair it with Firebase. Since Flamelink is built on Firebase, you’ll also have headless CMS in a jaw-droppingly short amount of time.</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F8Cw5ktNADBQ%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D8Cw5ktNADBQ&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F8Cw5ktNADBQ%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/d7ada5b89df31f1d896960476d4cc423/href">https://medium.com/media/d7ada5b89df31f1d896960476d4cc423/href</a></iframe><p>Flamelink is well-built and powerful in its own right! I’ve been using this tool for personal projects for over a year now and since I started using it so many awesome features have been added. their attentive approach to <a href="https://flamelink.io/support">customer service</a> has also impressed me. I’ve had a couple of head-scratching moments where I didn’t know why something was broken, but they promptly helped me fix whatever was wrong with my setup. Not only do they have a great product, but the company is hard-working and staffed with the nicest folks! That’s been my experience so far.</p><p>Now I’ll walk you through the practical steps to getting started with Flamelink in your Angular application.</p><figure><img alt="Firebase logo" src="https://cdn-images-1.medium.com/max/225/1*qvSawCk_m7-iXCHnHGcUjA.png" /></figure><h3>Get Started With Flamelink, Firebase, and Angular</h3><p>There are three parts in this practical guide to setting up Flamelink in your Angular application:</p><h4>Part 1: Set up Firebase</h4><figure><img alt="4 screen shots which capture the setup instructions for a new Firebase project. Go to firebase to see the same screens." src="https://cdn-images-1.medium.com/max/1024/1*gOA4cvKuZphvOaQ0DUf4yQ.png" /><figcaption>Setting up a new Firebase project.</figcaption></figure><ol><li>Register or login to your Firebase account and create a new project. <em>See screenshot above.</em></li><li>Configure your new Firebase project. <em>See screenshot below.</em></li></ol><figure><img alt="Shows sign-in authentication settings in a Firebase project." src="https://cdn-images-1.medium.com/max/1024/0*tpwCSIb7sUrcuhuD" /><figcaption>Configuration 1: Set up authentication in Firebase so that you can log in via Flamelink.</figcaption></figure><figure><img alt="Authorized domains screen from Firebase project configuration." src="https://cdn-images-1.medium.com/max/1024/1*d1vRlR-joALY3BQrvmc5ig.png" /><figcaption>Configuration 2: Configure authorized domains.</figcaption></figure><figure><img alt="Cloud firestore rules setting." src="https://cdn-images-1.medium.com/max/849/1*5ws8W20El0E_-_aZqnG0pQ.png" /><figcaption>Configuration 3: Set database rules. Here’s an example.</figcaption></figure><figure><img alt="Firebase storage rules setting." src="https://cdn-images-1.medium.com/max/839/1*h-9nBBJcF5APXimTQ61hTQ.png" /><figcaption>Configuration 4: Set storage rules. Here’s an example.</figcaption></figure><h4>Part 2: Set up Flamelink</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WodQdwOubrdtPwdzqsn2lg.png" /><figcaption>Flamelink project creation example of first part.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_qOEpFt5h9noWyovnMZPcQ.png" /><figcaption>Flamelink project creation example of second part.</figcaption></figure><ol><li>Register or login to your Flamelink account and create a new project. <em>See screenshots above.</em></li><li>Configure your new Flamelink project.</li></ol><p>First, add some new schemas using the tools in the Flamelink web application for each type of content you want to be able to create. <em>See screenshots below.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/662/0*w4K0Z6g0u09xQD4R" /><figcaption>Create your schemas.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uRw0CuJ7Ln_EvkBm9T_UGw.png" /><figcaption>This is what the schema creation process actually looks like. Note the user-friendly drag and drop and clean building of various fields into each schema.</figcaption></figure><p>This is the moment we’ve all been waiting for — adding the content! So next you’re going to add some content to each of the collections which are labeled by their schema.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/0*mtRXqUU-hjbNuQSk" /><figcaption>Create your first content from your schemas.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Iqod_Rn4_6zCNXW0e09pQ.png" /><figcaption>This is what the content creation process looks like. It’s based directly off of the schema you created for the content. It supports validation of various kinds and multiple languages. You can even determine when it should be published!</figcaption></figure><p>Once you’ve added schemas and content to each schema, you’re ready to see your content come alive in an Angular application. The anticipation is palpable at this point!</p><h4>Part 3: Build an Angular App</h4><ol><li><strong>Create your new Angular app or use one you’ve already made.</strong> See <a href="https://angular.io/start">https://angular.io/start</a> for help making the app.</li><li><strong>Install the following dependencies:</strong> @angular/fire, firebase, firebaseui, firebaseui-angular, flamelink</li><li><strong>Set up Firebase in your Angular app.</strong> Depending on your needs, this might be as easy as adding the firebase config to your environment file and then loading it and moving on to the Flamelink setup steps. That would be true if you are providing content publicly. If you need to put your content behind an auth wall, see my <a href="https://github.com/erik-slack/Angular-Flamelink-Firebase">github example app</a> for more details.</li><li><strong>Set up Flamelink in your app. </strong>I decided to make a service for all of my Flamelink logic. Again refer to my <a href="https://github.com/erik-slack/Angular-Flamelink-Firebase">github example app</a> for more details on the specifics.</li></ol><p>Now that your application is set up and you’re seeing content powered by Flamelink, let me bestow upon you a bit more of my perspective. I’ll share with you some things you can do that are beyond the scope of this article — and if enough people comment and ask me to delve more into these more advanced Flamelink topics then I’ll do so. I also want to share some things that you should be aware of regarding security when using Flamelink and Firebase.</p><h3>Advanced Usages of Flamelink</h3><h4>Using Flamelink with NGRX</h4><p>Something to note is that Flamelink can work seamlessly with <a href="https://ngrx.io/docs">NGRX</a> store which is a tool for state management in Angular based on RxJS. Get your data via @ngrx/effects from Flamelink and store it to be selected via selectors by your components. With the proper caching of network requests and by using the super-powerful selectors of NGRX you can optimize the usage of your Firebase data to reduce the costs significantly. Keep in mind it’s only free to use Firebase up to certain thresholds of the various features it offers. Click <a href="https://firebase.google.com/pricing">here</a> to see Firebase pricing details.</p><figure><img alt="Logo of nrwl/nx." src="https://cdn-images-1.medium.com/max/400/1*QY9IfY-jvSEsoj8hVttG2g.png" /><figcaption>Nx brings monorepo with exceptional tooling to Angular and other frameworks.</figcaption></figure><h4>Using Flamelink with NRWL/NX</h4><p>I’ve used Flamelink without any issue in my <a href="https://nx.dev/angular">NX monorepo</a> with great success and no amount of increased frustration. I bring this up because this is a popular way to build Angular apps, and I’m a big fan even for smaller projects.</p><h3>Some Insights and Tips</h3><h4>Secure Your Database!</h4><p>I’m not an expert on this yet, but I’ve learned that you need to be wise about securing your Firebase to avoid giving too much access to your DB. Read this article to learn how to <a href="https://itnext.io/how-to-set-firebase-security-rules-for-your-flamelink-project-d855e8210198">secure your database if you used RTDB</a>. If like me you used Cloud Firestore, <a href="https://intercom.help/flamelink/en/articles/3068550-flamelink-and-cloud-firestore">here’s an article that can help you with that</a>.</p><h4>Touching On SDKs</h4><p>There are currently two javascript sdks for Flamelink and the newer one I used is <a href="https://flamelink.github.io/flamelink-js-sdk/#/">https://flamelink.github.io/flamelink-js-sdk/#/</a>. The older one looks exactly like the newer one so watch the url to make sure you’ve got the right one. Their sdk is pretty great, but I’ve noted several bugs over the past year in it. That’s to be expected as it’s still in Alpha. Filtering, Sorting, Limits, etc. are all possible using this sdk.</p><h4>What About Support?</h4><p>If you need support from Flamelink there are several avenues available to you. If you pay top dollar for it, you can get direct support from the company that is fast and nuanced to your specific needs. If you’re on the free or cheaper plans you can still get support through the Flamelink community slack. There are channels for all of the different platforms and general things as well. I’ve always gotten great responses to every question, and I rate their service as 5 stars. Oh, and those bugs I found in their sdk which I mentioned last paragraph? They fixed or addressed every one of them. This is a community that invests back into itself.</p><h3>Special Offer From Flamelink to Our Readers</h3><p>The Flamelink team has an exclusive offer for readers of the ng-conf publication. Sign up for any paid Flamelink project using the <strong><em>NGCONF-FLAMELINK-20</em></strong> promo code before September 30, 2020 and get 20% off your subscription for 3 months. There are only 100 coupons up for grabs, so sign up today to see how Flamelink can help add value to your Firebase project.</p><h3>Conclusion</h3><p>I consider Flamelink to be another very valuable tool in my application development toolkit and I hope you enjoyed learning about it together. Flamelink isn’t meant to solve every problem with your website, and there are many cases where using it probably wouldn’t make much sense. It WILL help if your app has large amounts of content or you just want to separate the responsibility of the content from the development. Using Flamelink with Angular is easy. I can’t wait to see what you build with it. Please share back in comments as appropriate on how you have used the material in this article.</p><p>The final thought I want to touch on in this article is this — be proactive in suggesting Flamelink or another headless CMS to companies and clients who have a lot of frequently changing content. Speak up and you could possibly turn a tedious chore into a career power-move that not only impresses your clients or bosses, but makes your job that much easier.</p><p><em>This article is adapted and expanded from a talk I gave at the </em><a href="https://www.meetup.com/AngularUtah"><em>UT Angular Meetup</em></a><em> in 2019.</em></p><h4>Links:</h4><ul><li>Flamelink: <a href="https://flamelink.io/">https://flamelink.io/</a></li><li>Flamelink Support: <a href="https://flamelink.io/support">https://flamelink.io/support</a></li><li>Firebase: <a href="https://firebase.google.com/">https://firebase.google.com/</a></li><li>My Example Repo: <a href="https://github.com/erik-slack/Angular-Flamelink-Firebase">https://github.com/erik-slack/Angular-Flamelink-Firebase</a></li><li>SDK: <a href="https://flamelink.github.io/flamelink/#/getting-started">https://flamelink.github.io/flamelink/#/getting-started</a></li></ul><h3>EnterpriseNG is coming November 4th &amp; 5th, 2021.</h3><p>Come hear top community speakers, experts, leaders, and the Angular team present for 2 stacked days on everything you need to make the most of Angular in your enterprise applications.<br>Topics will be focused on the following four areas:<br> • Monorepos<br> • Micro frontends<br> • Performance &amp; Scalability<br> • Maintainability &amp; Quality<br>Learn more here &gt;&gt; <a href="https://enterprise.ng-conf.org/">https://enterprise.ng-conf.org/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2604ed9a157b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ngconf/build-sell-apps-not-content-angular-with-flamelink-and-firebase-2604ed9a157b">Build &amp; Sell Apps, Not Content — Angular with Flamelink and Firebase</a> was originally published in <a href="https://medium.com/ngconf">ngconf</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>