<?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[EmberMap - Medium]]></title>
        <description><![CDATA[Principles and techniques for Ember.js developers, from the creators of https://embermap.com. - Medium]]></description>
        <link>https://medium.com/embermap?source=rss----d58ea1184bbb---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>EmberMap - Medium</title>
            <link>https://medium.com/embermap?source=rss----d58ea1184bbb---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 14:15:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/embermap" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Safety of the herd]]></title>
            <link>https://medium.com/embermap/safety-of-the-herd-8d64f9170299?source=rss----d58ea1184bbb---4</link>
            <guid isPermaLink="false">https://medium.com/p/8d64f9170299</guid>
            <category><![CDATA[ember]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Ryan Toronto]]></dc:creator>
            <pubDate>Tue, 17 Jan 2017 16:45:32 GMT</pubDate>
            <atom:updated>2017-02-24T18:09:21.546Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LI8kxU_23IFMoxJHtBlL0w.jpeg" /><figcaption>Photo by Joel Herzog (<a href="https://unsplash.com/photos/2Nvfrm2wLQY">unsplash</a>)</figcaption></figure><p>“People are asking about routable components because they want to know how to make their apps future-proof. This kind of thinking leads someone to say, ‘<em>you should never use controllers because they’re going away</em>’. But the safest place to be in Ember is in the safety of the herd.”</p><p>Edward Faulkner made this point while speaking at a recent Boston Ember meetup, and it captures one of the reasons why I love using this framework so much: it’s the idea that you can code with Ember’s established conventions today, and be safe as Ember changes in the future.</p><p>Ember developers will recognize this safety in Ember CLI, and how it’s saved them from pouring time into a build tool that became obsolete; in Ember Data and JSON:API, which provides a durable baseline approach for how their backends should represent relationships, pagination, filtering, and sorting; and in so many other decisions that they’re able to delegate to the community.</p><p>But when Ember changes and evolves, it’s tempting to view this safety as stagnation. We want to take advantage of new practices right away — and as a result, we often find ourselves wanting to leave the herd.</p><p>I’ve left the herd several times. I’ve feared that if I’m not using future patterns in my code, my applications will end up full of technical debt. In fact, the reality is just the opposite. When I try to predict future Ember or cargo-cult a new but unproven pattern, I dig myself into a hole. By veering off the path, I can find myself so far from the herd that it’s almost impossible to rejoin it. The irony is that my current attempts to prevent future technical debt often end up being the main causes of actual technical debt within my codebases.</p><p>The leaders of the Ember community understand this. They know that a team paralyzed with doubt about whether they’re coding using modern techniques won’t be able to focus on writing the best apps they can today. And this is why changes to the framework are always accompanied by an upgrade path for older apps. “The goal is not to try to guess ahead, hack, and pretend you’re in future Ember,” Edward said. “Just stick with the most conventional way of writing Ember apps today.” There will be an upgrade path.</p><p>A great example of this is the upcoming change to module imports. Although this change will affect how we write Ember in the future, none of us need to start using this new syntax today — the RFC includes a <a href="https://github.com/tomdale/rfcs/blob/js-modules/text/0000-javascript-module-api.md#migration">migration tool</a> that will automatically convert all imports to the new format. Everyone should continue working just as they are, and when the new module format is ready you’ll be able to transition your app with ease.</p><p>So, if you’re worried about future-proofing your Ember apps, trying to anticipate future features is risky, distracting and unnecessary. Your best bet is just sticking with the herd. But what about trying new libraries and techniques from outside the Ember community?</p><p>The fact that Ember developers can so easily experiment with new tools is amazing, and addons are a great way to try out new ideas long before they end up in the framework. However, just like trying to future-proof your app can lead to problems, leaving the herd to experiment with cutting-edge techniques can potentially make your app harder to upgrade in the future.</p><p>If you decide to break off from Ember’s conventions, it’s good to ask, “Will I be able to rejoin the herd?” If not, how will that affect your application? There’s no single right answer here. It depends on what you’re building and who you’re working with.</p><p>Also, it can sometimes be hard to know where your application stands relative to the herd. I often experiment with new addons or feature flags, and in their early stages of development it’s not obvious how far they move me away from Ember’s upgrade paths.</p><p>Even so, it would be wrong for me to say that you should never leave the herd. Some amount of tinkering and experimentation is healthy, and we want our community to move forward when important new ideas arrive on the scene. As Yehuda Katz said at EmberConf 2016, “Eventually, all the good ideas will end up in Ember.”</p><p>So if you find yourself in a situation where you’re trying to work around Ember’s current functionality, take a step back and consider if it’s worth veering off the path. And as for your typical everyday development, set aside the future, focus on your app, and take comfort in the safety of the herd.</p><p><em>Watch our videos on </em><a href="https://embermap.com/"><em>https://embermap.com</em></a><em> to get your team up to speed on conventional Ember techniques.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8d64f9170299" width="1" height="1" alt=""><hr><p><a href="https://medium.com/embermap/safety-of-the-herd-8d64f9170299">Safety of the herd</a> was originally published in <a href="https://medium.com/embermap">EmberMap</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a sticky chatbox]]></title>
            <link>https://medium.com/embermap/building-a-sticky-chatbox-3d50272c2e0c?source=rss----d58ea1184bbb---4</link>
            <guid isPermaLink="false">https://medium.com/p/3d50272c2e0c</guid>
            <category><![CDATA[ember]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Sam Selikoff]]></dc:creator>
            <pubDate>Tue, 01 Nov 2016 15:36:13 GMT</pubDate>
            <atom:updated>2016-11-04T17:24:40.410Z</atom:updated>
            <content:encoded><![CDATA[<h4>Group learning at Ember NYC’s September project night</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hMP7-glqw-Oh4OYnTXz8gw.png" /><figcaption>Sonja Langfordvia <a href="https://unsplash.com/photos/RQHzRELE2Ss">unsplash</a></figcaption></figure><p>Last month I hosted Ember NYC’s project night, and the audience and I built a sticky chatbox component together. My goal wasn’t to end up with a prefabricated solution for everyone to use; instead, I wanted to work through the problem as a group, discussing our thought process and opinions as we went along.</p><p>I built this component last summer as part of a client prototype and found it an interesting and fun challenge. It looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*rjMhcSv9QyjHrmK9vqN5Qw.gif" /><figcaption>A plain div on the left, and our sticky chatbox on the right</figcaption></figure><p>Normally, when a scrollable &lt;div&gt; gets new content, its scrollbar is unaffected. You can see on the left that to keep reading, the user must scroll the chatbox each time a new message comes in.</p><p>The sticky chatbox on the right is different. When the user is scrolled to the bottom, new messages appear and “push” the chat log up, so the user doesn’t have to keep scrolling. But, if the user scrolls back up to read through older messages, the chat box doesn’t snap to the bottom. The scrollbar stays in place, so the user isn’t interrupted while reading through the log. This is the behavior found in most modern chat apps like Slack and Twitch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*DDXiSnPRjWaL0nJqpwhB1Q.gif" /><figcaption>Twitch’s chat is sticky, which makes it easy to keep up with the Internet’s most mature audience</figcaption></figure><h3>My approach</h3><p>When writing complex components, I like to start by identifying the various states in which the component can exist. Identifying state can be tricky; sometimes I find it helpful to try to explain how the interface should behave as if I were talking to a non-technical business or product person. How might we talk about this component together?</p><blockquote>When the user is scrolled to the bottom, new messages should show up. If they scroll up to read old messages, the chat should stay still.</blockquote><p>From this plain-English description, the states of the component jump out at us:</p><ol><li>The user is scrolled to the bottom</li><li>The user is not scrolled to the bottom</li></ol><p>Of course, we can think of other states in which the component could exist — for example, if the user was scrolled to the top — but those states aren’t relevant here, since they don’t affect behavior. The only states that affect behavior are the two we’ve listed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1EHxfCgN8km-7WRZkUQnMw.png" /><figcaption>The two possible states of our component: scrolled to bottom (left) and not (right)</figcaption></figure><p>Given these possible states, I gave my component an isScrolledToBottom boolean property that I could use to adjust the component’s scrolling behavior. I then needed to update this property every time the state of the component changed.</p><p>How might I achieve this? The first thing that came to mind was an addon I had used in previous projects: DockYard’s <a href="https://github.com/dockyard/ember-in-viewport"><em>Ember In Viewport</em></a>. This addon lets you render a component to the screen that fires an action whenever that component enters or exits the viewport.</p><p>Sounds like just what I needed. If I rendered this component at the end of the chat list, I‘d then be able to know whenever the user reached the bottom, and set the state accordingly. If they started scrolling up to read old messages, the component would leave the viewport, and I’d be able to use another action to update the state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4Z-1zRILm1wGAYkZskr-GA.gif" /><figcaption>The {{in-viewport}} component in action, at the end of the messages list</figcaption></figure><p>So, I wrote a simple {{in-viewport}} component using the mixin from the addon. You can see the full implementation of that component in the Twiddle below. I then used it in my component’s template:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9c8ab795af0fb1e1be0e607e7b93c2e6/href">https://medium.com/media/9c8ab795af0fb1e1be0e607e7b93c2e6/href</a></iframe><p>All that remained was to write the component’s behavior. If the user was scrolled to the bottom, the component’s &lt;ul&gt; should scroll down each time a new message was rendered. The scrolling should happen after the new message was appended to the DOM — sounds like a perfect use case for the <a href="http://emberjs.com/api/classes/Ember.Component.html#method_didRender">didRender</a> hook:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2e4b8bdae6d78e39ca8debd4b392f9af/href">https://medium.com/media/2e4b8bdae6d78e39ca8debd4b392f9af/href</a></iframe><p>Et voilà! Our chat box lets the user read through the backlog, and then autoscrolls when they’re all caught up.</p><p>Check out this Twiddle for a full working example:</p><p><a href="https://ember-twiddle.com/92b9e154ed4b8dc554727bf794da88f6?openFiles=templates.components.chat-box.hbs%2C">Ember Twiddle</a></p><h3>The group’s approach</h3><p>To my delight, several members of the group from the project night suggested a completely different strategy. The idea was simple: check the state of the scrollbar the moment a new message arrives. If the scrollbar was at the bottom, autoscroll the chatbox; otherwise, leave it alone.</p><p>We still needed to store the state of the scrollbar, so we kept the isScrolledToBottom property; but now, we needed to set this property whenever the component was about to re-render.</p><p>It took a bit of experimentation. We started out by trying to calculate the scroll position at the beginning of the didRender hook. The problem here is that in didRender, the chatbox had already been updated — so even if the user <em>had</em> been scrolled to the bottom, the fact that the new message had already been appended meant they no longer were.</p><p>Eventually we realized that we needed to calculate the scroll position just <em>before</em> the new message was added to the DOM. We pulled up the guides for a component’s <a href="https://guides.emberjs.com/v2.9.0/components/the-component-lifecycle/#toc_on-re-render">re-render lifecycle hooks</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*knXK5_N3-3-4MElfHvOqCA.png" /><figcaption>Component initial and re-render lifecycle hooks</figcaption></figure><p>Both willUpdate and willRender seemed like good candidates. Looking at the documentation for each, we found that <a href="http://emberjs.com/api/classes/Ember.Component.html#method_willRender">willRender</a> is called on both initial render and re-renders, while <a href="http://emberjs.com/api/classes/Ember.Component.html#method_willUpdate">willUpdate</a> is only called on re-renders. Since we only cared about new messages, we went with willUpdate.</p><p>After a little more experimentation, we were able to write a formula to calculate the state of the scrollbar. We then used this formula to set the component’s state in willUpdate:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/666c9b43d187c12a002acec4b243fd51/href">https://medium.com/media/666c9b43d187c12a002acec4b243fd51/href</a></iframe><p>Now the state would be correct even after the new messages were appended, so the code in didRender worked just as before. Cool!</p><p>Here’s the Twiddle:</p><p><a href="https://ember-twiddle.com/bfca7855e100560b62651f0cb7673963?openFiles=components.chat-box.js%2C">Ember Twiddle</a></p><h3>Tradeoffs</h3><p>After going through both solutions, Luke Melia pointed out that spying on scroll behavior is quite expensive (which is why the Ember In Viewport addon makes you explicitly opt-in to this behavior). He said that using the first approach could significantly affect performance, especially on mobile. In many cases, then, the willUpdate solution would be the superior choice.</p><p>For our demo app, the willUpdate solution was sufficient — the only time we used the isScrolledToBottom property was when re-rendering the list. If you open the Twiddle, however, you’ll notice that the state of our component can “lie”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/479/1*A2GnvE97x1Xa40Xazm4NVA.gif" /></figure><p>If you scroll the chatbox after a new message has been rendered, you‘ll notice that the isScrolledToBottom property won’t change right away; in fact, it won’t update to reflect the “true” state of the scrollbar until the next message arrives.</p><p>If we were to add additional behavior to this component that relied on isScrolledToBottom being accurate, we could run into some issues. How might this happen? You could imagine updating the interface to show an indicator that new messages had arrived. You’d want that indicator to clear once the user had read through all the messages. In this case, there could be a long time between when the user had caught up and when the next message arrived, so the interface could fall “out of sync” with the actual state of the user’s behavior.</p><p>This is just one example of something that could affect your decision. Different approaches often favor competing goals, like performance versus accuracy. It’s up to you to decide which strategy is most appropriate based on the unique priorities and needs of your application.</p><h3>Conclusion</h3><p>Building the sticky chatbox as a group helped us all see the problem with a bit more clarity. We learned</p><ul><li>Spying on viewport scrolling is expensive, and should only be done when necessary.</li><li>The willRender and willUpdate hooks are a great place to take measurements or perform visual calculations on a component’s DOM before Ember re-renders it.</li><li>The didRender hook is useful if you need to update a component’s DOM in response to a re-render, for example after the component receives new attrs.</li><li>Nearly all design decisions have tradeoffs.</li></ul><p>So reference the API docs often, keep pairing, and if you’re in New York be sure to join us at <a href="https://www.meetup.com/EmberJS-NYC/">Ember NYC’s</a> next Project Night!</p><p><em>Hungry for more? Check out </em><a href="https://embermap.com/"><em>embermap.com</em></a><em> for our latest thoughts, blog posts and videos on Ember.js.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d50272c2e0c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/embermap/building-a-sticky-chatbox-3d50272c2e0c">Building a sticky chatbox</a> was originally published in <a href="https://medium.com/embermap">EmberMap</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data flow in Ember applications]]></title>
            <link>https://medium.com/embermap/passing-data-around-your-ember-application-c4fe1e06e90?source=rss----d58ea1184bbb---4</link>
            <guid isPermaLink="false">https://medium.com/p/c4fe1e06e90</guid>
            <dc:creator><![CDATA[Ryan Toronto]]></dc:creator>
            <pubDate>Tue, 13 Sep 2016 12:01:01 GMT</pubDate>
            <atom:updated>2016-09-13T15:38:07.107Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h95wbcIxWR8DXqjR8VxowA.png" /></figure><p>Data flow might just be the hardest part of writing a stateful client application. Proper data flow can make or break your Ember app, and the key to success is understanding all your options and knowing when each is most appropriate.</p><h4>Data down</h4><p>The most straight-forward way of getting data into a component is by passing it during template invocation, better known as <em>data down</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-uBsxhq_1_jVA56rZpcL0w.png" /></figure><p>The explicitness is good — it tells other developers what they need to know about using your components, since there’s no hidden state. Which would you rather debug: <em>{{edit-current-post}}</em> or <em>{{edit-post post=currentPost}}</em>?</p><p>Explicitness also keeps your templates self-explanatory. Just looking at a template is enough to get a good idea of what data will be displayed, how components compose with each other, and what’s needed for each component to render.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fd41edb667b5daca7de467f4d8885dc5/href">https://medium.com/media/fd41edb667b5daca7de467f4d8885dc5/href</a></iframe><p>The downside of this approach is that as you develop your application, there’s a tendency to pass data to some components just so that it can be passed to other components. This creates a Middleman problem — you don’t know if a component is being passed data because it actually needs it, or because a nested component needs it. The explicitness is lost.</p><p><a href="https://embermap.com/topics/refactorings/reducing-component-arguments">This video</a> outlines some problems that come from Middleman components, and discusses some possible solutions.</p><h4>Injection</h4><p>One way to avoid needlessly passing data around your entire UI hierarchy is by using Ember’s excellent dependency injection system.</p><p>Let’s say a component deep in your UI tree needs access to the Ember Data store. Rather than passing it through every component, you can give the nested component a direct reference to the store by using <em>Ember.inject.service()</em>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iOxGLGVLap9iMLi3DDlnLw.png" /></figure><p>Injection is commonly used for sharing singleton objects, especially those that represent application-wide state not tied to any particular UI component. For example, most of my Ember applications have a <em>currentUser</em> service that any component can access via injection. Here’s how my navigation menu uses this service:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d21b5d5d90d0816ed23b43abef1b3cd4/href">https://medium.com/media/d21b5d5d90d0816ed23b43abef1b3cd4/href</a></iframe><p>Be careful with services and injection. A few services are fine, but if you find yourself representing every object in your domain as a service, you’ve gone too far. A question I like to ask myself is, would I consider the thing this service represents a global variable? If yes, go ahead and create the service.</p><h4>Domain modeling</h4><p>Accessing data by traversing your model graph can dramatically simplify your component hierarchy, and is particularly appropriate for domain-specific components.</p><p>If you write a component to show a blog post’s comments, pass the post in and let the component figure out how to access and display those comments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*70YwS5qpJXnDoZAH7UrS-A.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3e3f074e12d0646dfd37ecaa565f505a/href">https://medium.com/media/3e3f074e12d0646dfd37ecaa565f505a/href</a></iframe><p>The reasoning here comes from the object-oriented design principle of <em>dependency direction</em>. Sandi Metz summarizes this principle quite nicely:</p><blockquote>If you were to give [your objects] advice about how to behave, you would tell them to <strong>depend on things that change less often than you do</strong>.</blockquote><p>So, the logic here is that our domain model — the fact that a post has many comments — is not likely to change that often, whereas our UI’s representation of those comments is. It’s easy to think about what changes we might want to make to the <em>{{post-comments}}</em> component: maybe we want to access author information from the post, or we might disable commenting after a certain period of time passes from the post’s publication date. Regardless of what we end up changing, the point is that it often makes sense to encapsulate domain knowledge within a component, making it more isolated and easy to change, and minimizing its external dependencies down to a single model or object.</p><p>Additionally, it’s good to think about how your data is modeled apart from any specific interface. UIs are often the most complex representations of your data. If you think first about how things are related before jumping into interface development, you’ll develop a good mental model for implementing those UIs later.</p><p>The biggest tradeoff when allowing components to traverse your domain is that the <em>{{post-comments}}</em> component is no longer reusable for other models.</p><h4>Imports</h4><p>JavaScript’s import statement is a fantastic and often overlooked way to pull data and functions into components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/972/1*o2TDLbvk9VEAK4FGp0s_aQ.png" /></figure><p>Say you have a component that needs to find the aspect ratio of an image. Simply import that function, and you’re off to the races:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f5b0faf952283fb21a96393536e6948e/href">https://medium.com/media/f5b0faf952283fb21a96393536e6948e/href</a></iframe><p>In general, imports work best for stateless functions that perform some sort of transformation on your data. If a function needs to access anything that cannot be passed in via its arguments, you might need to use some other approach.</p><h4>Configuration files</h4><p>Components sometimes need to know about global configuration data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wCFBj9ZDJQizYg5sAG3RuQ.png" /></figure><p>Imagine working on a component that polls the backend for new data. This component should run in all environments expect for <em>test.</em> An easy way to share this data is by importing the environment config:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/616580035af1df20821fc5409eb9204a/href">https://medium.com/media/616580035af1df20821fc5409eb9204a/href</a></iframe><p>Try not to litter your config with non-global options or data. It’s most appropriate for data that depends on either the run-time or build-time environment of your application.</p><h4>Yielding</h4><p>Think of Ember’s yield statement as the opposite of data down: it allows a component to pass data back up to it’s invoker.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xv79AxHwb4ghr0OucXjJZA.png" /></figure><p>Say you’re tasked with building a modal, and a requirement is that the caller needs to be able to customize how the close button is displayed. HTML and CSS are perfect for positioning, so it makes sense to treat this styling option as template code.</p><p>To achieve this, we’ll have the modal component yield a <em>close-button</em> that can be positioned from within the caller’s template:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a8ca78bb9ef9e6cc0ed3b5bd708bf60a/href">https://medium.com/media/a8ca78bb9ef9e6cc0ed3b5bd708bf60a/href</a></iframe><p>Using <em>yield</em> allows us to pre-wire the action so that the caller doesn’t have to reimplement the close button’s behavior. We now have a flexible modal component that can be easily reused throughout our application.</p><p><em>Yield</em> is a great way to share data between components, but it should only be used when you need to expose a new API. Expanding a component’s API puts additional responsibility on callers, and should only be done when it makes sense to transfer that burden.</p><h4>Wrapping up</h4><p>So, how do you know when to use each approach? Unfortunately, the best answer here is experience. Ember tries hard to nudge you in the right direction, so if something you’re doing feels really painful — too many Middlemen components, long lists of arguments, a proliferation of services — there’s a chance there’s a better method. Follow your instincts, talk with coworkers, and ask others in the community for a second opinion, and you’ll be on your way.</p><p><em>Keep deepening your data knowledge by checking out </em><a href="https://embermap.com/"><em>EmberMap.com</em></a><em>, a video and screen casting site for Ember developers.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c4fe1e06e90" width="1" height="1" alt=""><hr><p><a href="https://medium.com/embermap/passing-data-around-your-ember-application-c4fe1e06e90">Data flow in Ember applications</a> was originally published in <a href="https://medium.com/embermap">EmberMap</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lessons learned from four years with Ember]]></title>
            <link>https://medium.com/embermap/good-ember-developer-bad-ember-developer-7f9d52c6a0b5?source=rss----d58ea1184bbb---4</link>
            <guid isPermaLink="false">https://medium.com/p/7f9d52c6a0b5</guid>
            <category><![CDATA[ember]]></category>
            <dc:creator><![CDATA[Ryan Toronto]]></dc:creator>
            <pubDate>Tue, 16 Aug 2016 14:46:02 GMT</pubDate>
            <atom:updated>2016-08-20T06:31:04.337Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JCnzN_mKY0WWJKx2gTeSnQ.jpeg" /><figcaption>Elizabeth Lies (via <a href="https://unsplash.com/photos/YbgPWfWlvkE">unsplash</a>)</figcaption></figure><p>Having worked with Ember for four years now, it feels like a good time to take stock of all the lessons I’ve learned. Here are some good practices and bad habits that I’d share with myself if I could go back to when I was just starting out — and that I still find useful to be reminded of on a regular basis.</p><h4><strong>Component design</strong></h4><p>Avoid the temptation to immediately start creating components before a static design is agreed upon. Instead, start with static HTML, then break that HTML up into components that fit neatly within your site’s design.</p><p>Don’t prematurely abstract by designing components for maximum re-use and flexibility, making every action and property configurable. Instead, design components with readable APIs that fit within your application’s domain.</p><p>Understand all the states in which your components can exist. Don’t display blank screens.</p><p>Don’t {{yield this}}. Think carefully about how to yield as little as possible.</p><p>Compose components in your templates, and don’t fetishize mixins.</p><h4>Testing</h4><p>Test the code you’re responsible for. Avoid testing framework code.</p><p>Use component integration tests to test internal developer APIs and actions, and keep nearly all external user behavior, like clicking and filling in forms, in acceptance tests. Understand that your tests exist at different levels of abstraction, and consider the user — another developer? the end customer?— of the system under test.</p><p>Don’t make excuses for not testing, and learn how to avoid writing brittle tests.</p><h4>Community solutions</h4><p>Don’t try to solve every problem — learn how and when to use addons.</p><p>Allocate part of your development time to continuously learning: attending meet-ups, going to conferences, chatting in slack, contributing to addons, reading blogs, listening to podcasts, or engaging on Twitter. It’s easy to not make time for this, but the smallest bit of new knowledge can have a dramatic effect on your day-to-day work.</p><p>Put aside your favorite tool if doing so allows you to follow shared solutions. Ember is not just a tool, it’s a community — don’t be somebody that refuses to budge.</p><p>Learn how the framework evolves and changes. Read RFCs, share your frustrations, and experiment with solutions. Don’t feel entitled to the framework, and don’t complain about changes you disagree with but did nothing to influence.</p><h4>Routing</h4><p>Return a single model or collection from <em>model </em>hooks on your routes — doing so enforces good domain modeling. Don’t return <em>RSVP.hash</em> or <em>RSVP.all</em>.</p><p>Nest routes according to your UI designs; otherwise, loading data will be unnecessarily complicated.</p><h4>Asynchronous code</h4><p>Take time to understand that JavaScript-rendered applications are not just another way to do what server-rendered applications already do. Consider that you are working in a stateful environment, and dealing with activities that are fundamentally concurrent.</p><p>Learn why managing asynchronous code is so difficult, and look for abstractions that can help. Ignore this, and your apps will be littered with extraneous imperative code and buggy state machines.</p><p>Write apps that are aware of when they’re transitioning, running many activities, or offline. Don’t write static apps.</p><h4>HTTP APIs</h4><p>Avoid writing hand-coded bespoke HTTP APIs. Understand the benefits of JSON:API, and be able to explain them to your team.</p><p>Learn how data is loaded and flows through your application. Learn about the various states of your data store, and avoid writing N+1 query bugs in your templates.</p><p>Take time to think about the one-to-one, one-to-many, and many-to-many relationships in your application. Don’t treat these as a backend problem.</p><p>Perform CRUD operations on resources, including join records. Don’t make new abstractions just to limit your frontend’s exposure to the domain model.</p><h4>Code and design</h4><p>Always consider tradeoffs when applying design patterns. Don’t lock onto a small set of concepts and apply them to your entire codebase.</p><p>It’s easy to get upset at Ember when your code doesn’t work the way you expect. Lots of thought and consideration went into Ember — take time to understand its conventions, and investigate the reasoning behind non-obvious design decisions that frustrate you.</p><h4>Teammates</h4><p>Don’t complain when a co-worker makes a mistake. Instead, take time to discuss best practices. You’ll both learn something new and exciting.</p><p>Don’t avoid asking for feedback about your component APIs or complain about bikeshedding. API design, like documentation and styleguides, is another form of communication, and is critical to the long-term success of any application.</p><p><em>We started EmberMap to share the lessons we’ve learned with others. Watch our videos at </em><a href="https://embermap.com/"><em>embermap.com</em></a><em> or </em><a href="https://twitter.com/ember_map"><em>follow us on Twitter</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f9d52c6a0b5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/embermap/good-ember-developer-bad-ember-developer-7f9d52c6a0b5">Lessons learned from four years with Ember</a> was originally published in <a href="https://medium.com/embermap">EmberMap</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lowest Common Ancestor]]></title>
            <link>https://medium.com/embermap/lowest-common-ancestor-fbf5d5313a1?source=rss----d58ea1184bbb---4</link>
            <guid isPermaLink="false">https://medium.com/p/fbf5d5313a1</guid>
            <category><![CDATA[ember]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[ui]]></category>
            <dc:creator><![CDATA[Sam Selikoff]]></dc:creator>
            <pubDate>Mon, 25 Jul 2016 16:53:56 GMT</pubDate>
            <atom:updated>2016-01-16T15:03:09.497Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vEfg-DhKH0A-YMZBjnIQ_w.png" /></figure><p>One of the biggest challenges when writing a JavaScript application is keeping multiple parts of the interface in sync. A user interaction in one part of the interface often affects data in another. If not managed well, this data can end up in multiple places, but with inconsistent values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iWOpHOULxmsJlsiO.gif" /><figcaption>Email 1 being unread is a piece of application state that affects multiple parts of the interface. After the email is read, the title should no longer be bold, and the Inbox unread count should decrease by one.</figcaption></figure><p>In the past few years, the JavaScript community has learned a lot about how to deal with this problem. The solution involves the principle of the <strong>Lowest Common Ancestor</strong>. To explain this principle, let’s look at some interface elements you might build while working on a real-world application.</p><p>These examples use Ember, but the principles are high-level and apply to any technology used for building long-lived JavaScript applications.</p><h3>A collapsible panel (a single view of app state)</h3><p>Let’s say we’re building an app with a collapsible panel:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/0*zG2-KZSkGIQJo7C4.gif" /><figcaption>A collapsible panel, an element that opens and closes when the user clicks on it.</figcaption></figure><p>Here’s the component’s template:</p><pre>&lt;a {{action &#39;toggleIsOpen&#39;}}&gt;Panel Title&lt;/a&gt;</pre><pre>{{#if isOpen}}<br>  &lt;div&gt;Anim pariatur cliche...&lt;/div&gt;<br>{{/if}}</pre><p>If the panel <em>isOpen</em>, we’ll show the body. Clicking the title triggers the <em>toggleIsOpen</em> action.</p><p>Here’s the component’s JavaScript:</p><pre>export default Ember.Component.extend({</pre><pre>  isOpen: true,</pre><pre>  actions: {<br>    toggleIsOpen() {<br>      this.toggleProperty(&#39;isOpen&#39;);<br>    }<br>  }</pre><pre>});</pre><p>The default value of <em>isOpen</em> is true, so the panel starts out open. Whenever a user clicks the title, <em>isOpen</em> toggles between true and false.</p><p>Currently, our application looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ROzRbyfqYv8zfc2-.png" /></figure><p><em>isOpen</em> is the only piece of state in our application that changes. Further, the collapsible panel is the only part of the interface that needs to know about it. Because of this, it makes sense for the panel itself to “own” this piece of application state. So, we’ll leave <em>isOpen</em> right where it is — as a simple property on the component.</p><h3>Adding a button (multiple views of app state)</h3><p>We have a new feature request: adding a separate button which can also toggle the panel. The button should also say “Expand” or “Collapse”, depending on the state of the panel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/0*UQ8MiTHYLB3Mw_WL.gif" /><figcaption>A collapsible panel and a button, which both depend on the same state.</figcaption></figure><p>We now have two elements in our application whose view depends on the same piece of state. What should we do?</p><p>One option is to add an <em>isOpen</em> property to our &lt;button&gt; component, and try to keep both properties in sync:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lPQB6k7JF6vyxps3.png" /></figure><p>But, duplicating state like this is not a good solution, because it can easily lead to an inconsistent interface.</p><p>A better solution is to move the state up a level to &lt;app&gt;, and have &lt;app&gt; pass down <em>isOpen</em> to both &lt;collapsible-panel&gt; and &lt;button&gt;:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CWMDAkQMt9JmkWew.png" /></figure><p>Think of the <em>isOpen</em> properties on the two children as read-only pointers to the <em>isOpen</em> property on &lt;app&gt;. Now, both &lt;collapsible-panel&gt; and &lt;button&gt; are guaranteed to stay in sync, since they’re rendered from the same state.</p><p>Here’s the template for &lt;app&gt;:</p><pre>{{collapsible-panel isOpen=isOpen onClick=(action &#39;toggleIsOpen&#39;)}}</pre><pre>{{button isOpen=isOpen onClick=(action &#39;toggleIsOpen&#39;)}}</pre><p>And here’s the JS, which looks exactly the same as &lt;collapsible-panel&gt; did in the first example:</p><pre>export default Ember.Component.extend({</pre><pre>  isOpen: true,</pre><pre>  actions: {<br>    toggleIsOpen() {<br>      this.toggleProperty(&#39;isOpen&#39;);<br>    }<br>  }</pre><pre>});</pre><p>When the user clicks either the &lt;collapsible-panel&gt; or the &lt;button&gt;, we’ll send an action up to &lt;app&gt;, which will then change its <em>isOpen</em> property. The new value of <em>isOpen</em> propagates throughout the rest of the app, and the problem of inconsistent interface elements goes away.</p><p>Crucially, we’ve made sure that only the owner of the state — &lt;app&gt;, in this case — is able to change that state. The children delegate their actions up to the owner.</p><p>By moving the state up to &lt;app&gt; and giving <em>isOpen</em> a single source of truth, we were able to ensure that &lt;collapsible-panel&gt; and &lt;button&gt; would never fall out of sync.</p><p>In the example above, &lt;app&gt; was the <em>only</em> ancestor of both components in our component tree. Say we had a larger app:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_QbQBOIqNw16Q06G.png" /></figure><p>In this case, it would be sufficient to move <em>isOpen</em> to &lt;main&gt; to ensure <em>isOpen</em> had a single source of truth.</p><p>Now, a definition. Given a set of components, the <em>Lowest Common Ancestor</em> of this set is the component that’s deepest in the UI tree but still above each component in that set.</p><p>This definition along with the discussion above leads us to the following general principle:</p><blockquote>When dealing with changing application state that lives in your UI hierarchy, store that state in the <strong>Lowest Common Ancestor</strong> of all components that need it.</blockquote><p>Storing shared state on the LCA, and then having that common ancestor pass its state to the relevant children, ensures that the state will have a single source of truth, and that every component that renders from that state will stay in sync.</p><p>Note that it can sometimes be convenient to create a new common ancestor component, just for the sake of owning and managing the shared state.</p><h3>Adding a logout button (pulling app state out of the UI)</h3><p>In many situations, the principle of LCA is sufficient. State has a single source of truth, and is passed down to all children who need it. The problem you can run into, however, is when the LCA is very far away in your component hierarchy from the relevant children.</p><p>In this case, you can end up with many components acting as middlemen. These components must know about and pass along various pieces of shared state to leaf components, making your UI difficult to refactor. There’s even a <a href="https://sourcemaking.com/refactoring/smells/middle-man">code smell of the same name</a> in object-oriented design, suggesting that this is indeed a concern.</p><p>An example of how this could happen is if many components in your app needed to know about the current user:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/0*Eu_TM5olOlymLJNK.png" /><figcaption>In this app, data from the current user affects many components.</figcaption></figure><p>Assuming this many nodes need to know about the current user, the LCA would be &lt;app&gt;, and every component would need to pass along <em>currentUser</em> to every other component. This definitely smells like Middle Man.</p><p>The solution to this problem is to <em>pull the state out of the UI hierarchy</em>. The idea here is that, while <em>isOpen</em> in our earlier example corresponded directly to a particular onscreen UI element (whether the panel was open), <em>currentUser</em> does not. So, it doesn’t really make sense for &lt;app&gt; (or any other UI element) to “own” <em>currentUser</em>.</p><p>In Ember, we can use a Service to solve this problem (in React, you might use a Flux store). A Service is a long-lived data container that exists independent of the UI tree. After we set it up, components can use <em>dependency injection</em> to ask for the data in the Service. Importantly, their parent components are none the wiser.</p><pre>// app/services/current-user.js<br>export default Ember.Service.extend({<br>  name: &#39;Bob&#39;,<br>  email: &#39;bob@acme.com&#39;<br>});</pre><pre>// app/components/sidebar.js<br>export default Ember.Component.extend({<br>  currentUser: Ember.inject.service(&#39;current-user&#39;)<br>});</pre><p>Now, &lt;sidebar&gt; can access <em>currentUser</em> in its template:</p><pre>&lt;h2&gt;{{currentUser.name}}&lt;/h2&gt;</pre><p>&lt;sidebar&gt; has become more self-contained, making it easier to move around in the UI in later refactorings.</p><h3>Conclusion</h3><p>So, when should application state exist in the UI hierarchy, and when should it be pulled out? As in most areas of software design, there is no black and white answer. Instead, we must understand the tradeoffs involved, and make decisions on a case-by-case basis.</p><p>State that’s stored directly in the UI hierarchy is often easier to understand and requires less boilerplate; but, the more components that need a particular piece of state, the more brittle your UI hierarchy becomes. Eventually, it makes sense to move “popular state” into a UI-independent data container, an identity map which other components can read from.</p><p>The key insight is that <em>all changing application state should have a single owner</em>, and thus a single source of truth. Further, only the owner should be allowed to mutate that state. If the state lives in the UI hierarchy, the single owner should be the Lowest Common Ancestor of all components that need that state.</p><p>In closing,</p><ol><li>Start by storing state on local component instances</li><li>Once a piece of application state is needed by more than one component, move that state up to the LCA</li><li>Once there are many components acting as middlemen, or it feels wrong for any particular component to own some state, pull that state out of the UI hierarchy and into a data container (an Ember Service, a Flux store, etc.)</li></ol><p>While our example above might seem simple enough, this pattern goes a long way in keeping your application’s architecture consistent and easy to reason about.</p><p><em>Originally published at </em><a href="http://www.samselikoff.com/blog/lowest-common-ancestor/"><em>www.samselikoff.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fbf5d5313a1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/embermap/lowest-common-ancestor-fbf5d5313a1">Lowest Common Ancestor</a> was originally published in <a href="https://medium.com/embermap">EmberMap</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Ember.js TDD workflow]]></title>
            <link>https://medium.com/embermap/my-ember-js-tdd-workflow-47847c6dbdfa?source=rss----d58ea1184bbb---4</link>
            <guid isPermaLink="false">https://medium.com/p/47847c6dbdfa</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[ember]]></category>
            <category><![CDATA[testing]]></category>
            <dc:creator><![CDATA[Ryan Toronto]]></dc:creator>
            <pubDate>Mon, 25 Jul 2016 12:31:02 GMT</pubDate>
            <atom:updated>2016-07-27T17:47:01.001Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7mfDXFXVhC0dv85FxmZGfg.png" /></figure><p>One of the hardest things about developing new features for single page applications is dealing with transient state. Transient state is state that lives solely on the client, and is lost when the page is refreshed.</p><p>Imagine you’re working on a search feature in the admin section of your web app. This feature lets you</p><ol><li>Enter an email</li><li>See a list of matching users</li><li>Select multiple users, and then</li><li>Upgrade their accounts</li></ol><p>As you’re developing this feature, you end up repeating these steps each time the page reloads. Since Ember apps live reload each time we make a code change, you end up repeating these steps quite a bit. If you think about it, a lot of development time is spent manually interacting with the browser.</p><p>In the last year I’ve worked on a handful of Ember.js applications ranging in size from a few users to several thousands. I’ve found that using a good TDD workflow eliminates these painful and repetitive interactions that can really eat into development time. In this post I’ll outline how I use TDD with Ember.js, and how it’s changed my development experience for the better.</p><h4>Ember CLI, QUnit, and Testem</h4><p>Let’s walk through building the admin user search feature described above.</p><p>The first thing I’ll do is create an acceptance test using an Ember CLI generator: <em>ember g acceptance-test user-searching</em>. Then, I’ll start writing a test with fake functions.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e0e925c66379b61ce8e14caa06212634/href">https://medium.com/media/e0e925c66379b61ce8e14caa06212634/href</a></iframe><p>This test will fail because none of these functions exist, but that’s ok. We’re just trying to describe the user behavior in the clearest way possible.</p><h4>Ember CLI Mirage</h4><p>The next thing I’ll start to think about is how the back end needs to respond in order for this feature to work. The tests won’t use a real back end — they’ll use stubbed data — but this is the best time to think about how data will flow from the back end to the front end.</p><p>For this task there’s no better choice than <a href="http://www.ember-cli-mirage.com/">Ember CLI Mirage</a>, which allows you to quickly stub JSON:API endpoints. I’ll start by creating a user endpoint and stubbing out a user response.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4f41f3befbddf24ddd9676b9d8d23aa4/href">https://medium.com/media/4f41f3befbddf24ddd9676b9d8d23aa4/href</a></iframe><p>I’ll then add the following fake users to my test:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2a2792021fa638f2de051ceae798bf03/href">https://medium.com/media/2a2792021fa638f2de051ceae798bf03/href</a></iframe><p>Now when my test makes a request for ‘<em>/users?filter[email]=acme.com</em>’, its response will be a JSON:API document with the two users that were created in the test.</p><p>When using Mirage, I may write a custom route handler if the backend has complicated logic or transforms. But I always start with the default handlers, and expand them only when needed.</p><h4>Ember CLI Page Object</h4><p>In order to get the test passing I’ll begin turning those fake test functions I wrote earlier into real code. I’ve found <a href="http://ember-cli-page-object.js.org/">Ember CLI Page Object</a> to be the best library for this, as it lets me encapsulate all the ways users can interact with my UI inside of page objects.</p><p>Page objects are an abstraction that allow you to separate HTML and CSS from user interactions. With page objects, none of my tests will reference CSS classes, so they become more resilient to UI changes. It’s important that my page objects read as if I were telling a real user how to interact with the application.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e3cd5d2ef763feea2a7edf5e84abf41a/href">https://medium.com/media/e3cd5d2ef763feea2a7edf5e84abf41a/href</a></iframe><p>The <em>visitable</em>, <em>fillable</em>, and <em>clickable</em> helpers make it easy for the test to interact with the given elements. I’ll now update my test to use the page object:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4461560528b5445ef73286746a5c3c78/href">https://medium.com/media/4461560528b5445ef73286746a5c3c78/href</a></iframe><p>At this point I’m ready to start implementing the feature on the admin dashboard. Looking at our test and page object, there are three requirements that must be met:</p><ol><li>The search box must have the class <em>.User-search</em></li><li>Whenever text is entered into the search box, it must send off a request to `<em>/users?filter[email]=text</em>` and then display the results in the <em>.User-search-results</em> container.</li><li>Each user must have a button with class <em>.Upgrade-account</em>. When clicked, it will upgrade the users account and display a success message.</li></ol><p>This is straightforward to do with Ember Data and the <em>{{input}}</em> helper. I’ll omit these code snippets here, but you can watch me build an app in detail using page objects in my EmberMap series on Acceptance Testing.</p><figure><a href="https://embermap.com/topics/acceptance-testing"><img alt="" src="https://cdn-images-1.medium.com/max/700/1*JqCHttjL9X0zU3fe-OAPrA.png" /></a></figure><h4>pauseTest()</h4><p>Sometimes, the raw test runner output isn’t enough to fully develop a feature. After all, I’m developing a UI — I need to see how it looks, and I want to interact with it at least a few times on my own.</p><p>To do this, I’ll use the <em>pauseTest</em> helper, which will freeze my test and let me interact with the application in its current state. It’s an indispensable tool while working on design, styling, or interactions.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7b6ef836ee608838465d8d0e60ce7e13/href">https://medium.com/media/7b6ef836ee608838465d8d0e60ce7e13/href</a></iframe><p>I’ll also use development mode for QUnit, which gives me a full-screen container. Here’s what it looks like when <em>pauseTest</em> and development mode are used together:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*fNMLe9uJqWzBQUOSYX4Jrg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*ad1Le1ACWyRcpDWJhiVChQ.gif" /><figcaption>pauseTest and development mode — indispensable tools for TDD with Ember</figcaption></figure><h4>More tests</h4><p>My single “search for a user by email” test is passing and I’ve got a page object that describes how to interact with the search feature. Next, I’ll duplicate this test, but instead of searching by email I’ll try searching by name:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fe0c23213ef82b9f4db7c15d80f6eb10/href">https://medium.com/media/fe0c23213ef82b9f4db7c15d80f6eb10/href</a></iframe><p>This test should pass right away, since all the heavy lifting is done by Mirage and our page object. Pretty incredible! It sounds obvious, but when tests are this easy to write, I find that I write more of them, which leaves me feeling more confident in my application’s behavior.</p><h4>Automating transient state</h4><p>When I talk about TDD, I’m quick to mention the benefits that come from knowing your application is working correctly. However, as I spend more time working on client-side applications, I’m finding that being able to automatically set up my application in various states, whether working on functionality or design, is a <em>huge</em> timesaver.</p><p>So, next time you find yourself repeating a series of user interactions over and over again just to test or design a feature, try using this technique. I guarantee you’ll be amazed by how much time you save.</p><p><em>If you’re excited and want to learn more about testing in Ember, head over to EmberMap and watch my ‘</em><a href="https://embermap.com/topics/acceptance-testing"><em>Acceptance Testing with Page Objects</em></a><em>’ video series today.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=47847c6dbdfa" width="1" height="1" alt=""><hr><p><a href="https://medium.com/embermap/my-ember-js-tdd-workflow-47847c6dbdfa">My Ember.js TDD workflow</a> was originally published in <a href="https://medium.com/embermap">EmberMap</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Welcome to EmberMap]]></title>
            <link>https://medium.com/embermap/welcome-to-embermap-70508071e0af?source=rss----d58ea1184bbb---4</link>
            <guid isPermaLink="false">https://medium.com/p/70508071e0af</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[ember]]></category>
            <dc:creator><![CDATA[Ryan Toronto]]></dc:creator>
            <pubDate>Sat, 23 Jul 2016 20:58:21 GMT</pubDate>
            <atom:updated>2016-07-23T20:57:36.029Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/486/1*czPp1fSMnNSg7mR2pa8Qgw.png" /></figure><p>Today we launched <a href="https://embermap.com/">EmberMap</a>, and we’re excited to share our first topic with you on <a href="https://embermap.com/topics/acceptance-testing">Acceptance testing</a>.</p><p>We started making videos because we wanted an efficient way to explain conventional Ember techniques to our own team. We’re strong believers in the power of conventions, and think a team that’s on board with the larger Ember community will be able to build products faster without accruing technical debt.</p><p>The Ember community regularly publishes a lot of content. For product teams looking to understand the essentials and keep their team up to date with larger changes in Ember patterns, it can be hard to know where where to look.</p><p>This is where EmberMap comes in. We’re making high-quality, focused content that teams can use to onboard new developers, refine their process, and serve as a springboard for discussion on how to solve unique problems facing their own organization.</p><p>We started with a topic that covers <a href="https://embermap.com/topics/acceptance-testing">Acceptance testing</a>, based on today’s best practices. This is important, because Ember is still a new framework, and still goes through change. The Acceptance Testing topic will be evergreen — if there’s a change in Ember that affects any of the code or concepts we’ve discussed in that topic, we’ll update the relevant parts and be sure to let you know. We think this will go a long way in giving teams an easy entry point for training new members, or even refreshing themselves on older topics, with the confidence that they’re learning how to do things according to modern best practices.</p><p>We can’t wait to hear what you think! We’re going to be focused on making more content and improving the site, so be sure to send us any feedback at <a href="https://twitter.com/samselikoff">@samselikoff</a> or <a href="https://twitter.com/ryantotweets">@ryantotweets</a>. Good luck, and happy learning!</p><p><em>Excited about Ember.js? Head over to </em><a href="https://embermap.com/"><em>embermap.com</em></a><em> to see what we’ve been working on.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=70508071e0af" width="1" height="1" alt=""><hr><p><a href="https://medium.com/embermap/welcome-to-embermap-70508071e0af">Welcome to EmberMap</a> was originally published in <a href="https://medium.com/embermap">EmberMap</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>