<?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 Inbal Sinai on Medium]]></title>
        <description><![CDATA[Stories by Inbal Sinai on Medium]]></description>
        <link>https://medium.com/@inbalsinai?source=rss-772a2245019c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*PmkvGC7D47WQC-Q500KE4w.jpeg</url>
            <title>Stories by Inbal Sinai on Medium</title>
            <link>https://medium.com/@inbalsinai?source=rss-772a2245019c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 15 Nov 2026 10:21:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@inbalsinai/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[Get Some “Elf”-Control for Your React State Management]]></title>
            <link>https://medium.com/@inbalsinai/get-some-elf-control-for-your-react-state-management-923d76856428?source=rss-772a2245019c------2</link>
            <guid isPermaLink="false">https://medium.com/p/923d76856428</guid>
            <category><![CDATA[state-management]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[rxjs]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Inbal Sinai]]></dc:creator>
            <pubDate>Wed, 27 Oct 2021 11:13:48 GMT</pubDate>
            <atom:updated>2021-10-27T11:17:20.625Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jjm6sexeKh7XXOByWuj2Zg.png" /></figure><p>While React has its fair share of state management solutions, Elf, the new kid on the block, aims to be the leanest, most modular solution yet. It’s built on top of RxJS and provides you with a wide array of tools to manage your state.</p><p>To acquaint yourself with everything Elf has to offer, check out <a href="https://netbasal.com/introducing-elf-a-reactive-store-with-magical-powers-for-js-apps-678d6cb0596f">Netanel Basal’s article</a>, then come back and read this article. It’s ok, I’ll wait 😉 You can also find extensive data on all of Elf capabilities in its <a href="https://ngneat.github.io/elf/">docs</a>. My aim in this article is to show some of those capabilities via an example.</p><h4>Setting up a Store with Elf</h4><p>The first step to set up a store with Elf is to figure out what we want to hold in the store state. In this case, we’re building the classic TODOs app, and allowing users to add or remove their own tasks, as well as mark them complete, so we’ll maintain a collection of TODO tasks.</p><p>To hold tasks in our state, we call the built-in method createState(). This method returns a state and a config, both used in the store creation. The parameters passed are features of the store — in this case we pass, withEntities means this is an entity store, representing a collection of similar entities (in this case, our TODOs). To use this feature, the @ngneat/elf-entities library needs to be installed. This can be done in a breeze using the <a href="https://ngneat.github.io/elf/docs/cli">Elf CLI</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0e39732393e64ccaf4d1ba16cc302dd1/href">https://medium.com/media/0e39732393e64ccaf4d1ba16cc302dd1/href</a></iframe><p>todos$ uses the build-in selectAll() entity method to return an Observable emitting the entire store’s TODO task collection.</p><p>updateTodosCompleted() uses the store.update() method to update our TODOs collection, in order to set a TODOs complete property. It receives a callback function, which gets the current state and returns a new immutable state — in our case we already have the built-in updateEntities() we can use here, another boilerplate saving solution from the Elf the entities package.</p><p>Similarly, addTodo() and deleteTodo() make use of the built-in addEntities() and deleteEntities() methods respectively, with addTodo() making sure that each new TODOs starts as incomplete, and gets it’s own id.</p><p>Now let’s create some TODOs and add them to our store:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/41ba7f4b40d43dba61bd2100aef9cff1/href">https://medium.com/media/41ba7f4b40d43dba61bd2100aef9cff1/href</a></iframe><p>This is the parent component which holds all our TODOs. We’re also using @ng-neat/use-observable here — it’s an additional library maintained by the creators of Elf which lets you use Observables in your React apps. useObservable() receives an Observable, subscribes to it, and stores the current version in a react state, ensuring that it persists between re-renders.</p><p>The parent component iterates over all the TODOs we have and displays each inside a TODO component. Let’s add that component:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6ca42f15c4b0a5095c1e02e57641e053/href">https://medium.com/media/6ca42f15c4b0a5095c1e02e57641e053/href</a></iframe><p>Clicking on a TODO’s delete button will lead via the parent to the repo’s deleteTodo() method, and clicking on the TODO task name itself will similarly toggle its completion state. Let’s add a component that enables us to add a task:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/54716759b558ad3ffa66d893b3b3c7e5/href">https://medium.com/media/54716759b558ad3ffa66d893b3b3c7e5/href</a></iframe><p>Now we can add, remove, and toggle task completion. But what about viewing only complete or incomplete tasks? Definitely a useful proposition 👍</p><p>To achieve that we can add the withProps() Store feature, which lets us add an additional property to our store — in this case a filter describing which TODOs the user wants to see at any given moment.</p><p>Now we can get a current value of the filter and use it to filter our Store entities, so we replace todos$ with visibleTodos$:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a0998086df35c8a1041ae2fc6ec52883/href">https://medium.com/media/a0998086df35c8a1041ae2fc6ec52883/href</a></iframe><p>We also add the updateFilter() method that uses store.update() to update the selected filter. All that remains it to update the parent component accordingly:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/665065ec862d19226514669df51dad01/href">https://medium.com/media/665065ec862d19226514669df51dad01/href</a></iframe><p>And add a filtering component that allows the user to choose between the available filters:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1ea99a8865317d5d4a15ffbc11eea076/href">https://medium.com/media/1ea99a8865317d5d4a15ffbc11eea076/href</a></iframe><p>Let’s see it in action:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*T5r78YQr22ujJiljbtVhug.gif" /></figure><p>Here’s the final result:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fstackblitz.com%2Fedit%2Freact-ts-f2mhqy%3Fembed%3D1%26file%3Dindex.tsx&amp;display_name=StackBlitz&amp;url=https%3A%2F%2Fstackblitz.com%2Fedit%2Freact-ts-f2mhqy%3Ffile%3Dindex.tsx&amp;image=https%3A%2F%2Fc.staticblitz.com%2Fassets%2Fsocial_editor-1e53e71ce7e2963fcef1b44837c4570c3fb10c8cb64b194a6eafa4e145d10edc.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=stackblitz" width="745" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/21e8426ed4c03390a11a1e93510c63aa/href">https://medium.com/media/21e8426ed4c03390a11a1e93510c63aa/href</a></iframe><p>I hope this gave you enough of an appetite to check out these features in Elf and some of other ones on offer, including, but not limited to:</p><ul><li>UI Entities</li><li>Cache management</li><li>DevTools</li><li>Request Management</li><li>Pagination Support</li><li>Persist State</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=923d76856428" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Get Some “Elf”-Control for Your Angular State Management]]></title>
            <link>https://medium.com/@inbalsinai/get-some-elf-control-for-your-angular-state-management-32c0bdfd2b02?source=rss-772a2245019c------2</link>
            <guid isPermaLink="false">https://medium.com/p/32c0bdfd2b02</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[rxjs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[state-management]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Inbal Sinai]]></dc:creator>
            <pubDate>Wed, 27 Oct 2021 11:13:21 GMT</pubDate>
            <atom:updated>2021-10-27T11:17:07.287Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*slF-4BzEjMf5S2Q_dKpRxA.png" /></figure><p>While Angular has its fair share of state management solutions, Elf, the new kid on the block, aims to be the leanest, most modular solution yet. It’s built on top of RxJS and provides you with a wide array of tools to manage your state.</p><p>To acquaint yourself with everything Elf has to offer, check out <a href="https://netbasal.com/introducing-elf-a-reactive-store-with-magical-powers-for-js-apps-678d6cb0596f">Netanel Basal’s article</a>, then come back and read this article. It’s ok, I’ll wait 😉 You can also find extensive data on all of Elf capabilities in its <a href="https://ngneat.github.io/elf/">docs</a>. My aim in this article is to show some of those capabilities via an example.</p><h4>Setting up a Store with Elf</h4><p>The first step to set up a store with Elf is to figure out what we want to hold in the store state. In this case, we’re building a website displaying a book database, and allowing users to build their own libraries from it, so we’ll maintain a collection of books.</p><p>To hold books in our state, we call the built-in method createState(). This method returns a state and a config, both used in the store creation. The parameters passed are features of the store — in this case we pass, withEntities means this is an entity store, representing a collection of similar entities (in this case, our books). To use this feature, the @ngneat/elf-entities library needs to be installed. This can be done in a breeze using the <a href="https://ngneat.github.io/elf/docs/cli">Elf CLI</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/21bddc2ad00a599203dcba9a866dd600/href">https://medium.com/media/21bddc2ad00a599203dcba9a866dd600/href</a></iframe><p>books$ uses the build-in selectAll() entity method to return an Observable emitting the entire store’s book collection.</p><p>setBooks() uses the store.update() method to update our book collection. It receives a callback function, which gets the current state and returns a new immutable state — in our case we already have the built-in setEntities() we can use here, another boilerplate saving solution from the Elf the entities package. Now let’s fetch some books and add them to our store:</p><h4>Populating the Store</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/950cd6313e17283a19c66b3a68c9a766/href">https://medium.com/media/950cd6313e17283a19c66b3a68c9a766/href</a></iframe><p>The service we’ve created handles the side-effects, but they can also be handled via Redux-inspired actions. You can read more about that <a href="https://ngneat.github.io/elf/docs/side-effects">here</a>. If we also wanted to add a loading state, that could easily be handled via the requests status package.</p><p>Let’s display our book collection:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2196b1825c61ca0b8ade11d2e1214a03/href">https://medium.com/media/2196b1825c61ca0b8ade11d2e1214a03/href</a></iframe><p>Now we can display it in our app:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/48c43c09a9102450bbe004ad16aee6bf/href">https://medium.com/media/48c43c09a9102450bbe004ad16aee6bf/href</a></iframe><p>In order to let the user maintain their own library by adding books from the collection, we add a library property in our state representing it. We could do that ourselves, but once again, Elf’s good the goods 🎁</p><h4>Adding a Store Property</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e930cb971b7033448092e5c3771fb281/href">https://medium.com/media/e930cb971b7033448092e5c3771fb281/href</a></iframe><p>The propsArrayFactory lets us add an array to our store via the generate feature (withLibraryIds). It also provides us with any methods we might need to maintain the array’s values. Let’s put some of those methods to use:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c7f9f081d5c07a8afd987093a297a19/href">https://medium.com/media/3c7f9f081d5c07a8afd987093a297a19/href</a></iframe><p>ownBooks$ supplies us with all the matching book data from our store, for the books in the user library. It does so using the selectLibraryIds() method generated by the propsArrayFactory and the Entities package’s built-in selectEntities(). So you see, the makers of Elf have thought of it all 😎</p><p>Finally, let’s add a component displaying the user’s library:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/920d3f12c5185f4ff454c60685e63c25/href">https://medium.com/media/920d3f12c5185f4ff454c60685e63c25/href</a></iframe><p>And add it to our app:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/889518ef656acdff00cc74e1a3e910dc/href">https://medium.com/media/889518ef656acdff00cc74e1a3e910dc/href</a></iframe><p>Let’s see it in action:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/1*DrhEHFrG93CWtsB24ml-kA.gif" /></figure><p>Here’s the final result:</p><p><a href="https://stackblitz.com/edit/angular-ivy-jz4tqu?file=src/app/books.service.ts">Elf State Management in Angular Apps - StackBlitz</a></p><p>I hope this gave you enough of an appetite to check out these features in Elf and some of other ones on offer, including, but not limited to:</p><ul><li>UI Entities</li><li>Cache management</li><li>DevTools</li><li>Request Management</li><li>Pagination Support</li><li>Persist State</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=32c0bdfd2b02" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Akita + React Hooks = a Recipe for Sensational State Management]]></title>
            <link>https://medium.com/datorama-engineering/akita-react-hooks-a-recipe-for-sensational-state-management-2fd077c6237c?source=rss-772a2245019c------2</link>
            <guid isPermaLink="false">https://medium.com/p/2fd077c6237c</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[akita]]></category>
            <category><![CDATA[js]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[state-management]]></category>
            <dc:creator><![CDATA[Inbal Sinai]]></dc:creator>
            <pubDate>Tue, 28 Jul 2020 07:08:18 GMT</pubDate>
            <atom:updated>2020-07-28T07:08:18.974Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*duuqq1nx9do6azW_NLCgZQ.png" /></figure><p>I’ve been working with Akita pretty much since its inception, and while I’ve created many, many Akita stores in Angular, and <a href="https://netbasal.com/form-fatale-how-akitas-form-manager-can-do-away-with-complex-multistep-form-logic-in-angular-329a557cc68">wrote</a> <a href="https://medium.com/better-programming/manage-your-state-navigation-data-with-a-breeze-using-angular-and-akita-5c90ce15ba9b">about</a> <a href="https://medium.com/hackernoon/lets-build-a-pizza-store-with-akita-state-management-for-angular-applications-de6ced65024d">it</a> <a href="https://medium.com/angular-in-depth/plan-your-next-party-with-an-angular-invite-app-using-akita-422495351767">extensively</a>, and even played around with an <a href="https://netbasal.com/supercharge-your-svelte-state-management-with-akita-f1f9de5ef43d">Akita/Svelte</a> combo, I had yet to use it myself in a React App. I’ve decided to check that box, and whip up a classic todo app in React, using Akita for state management. Let’s get cooking 👩‍🍳👨‍🍳</p><p>This article assumes some familiarity with Akita State Management. To learn more about Akita and all its capabilities, check out one of the articles I’ve listed above or its great <a href="https://datorama.github.io/akita/">documentation</a>.</p><h4>Getting Started — What Do We Want to Save, and Where Do We Want to Save It?</h4><p>We start by creating the model for the entity we want to save, in this case a ToDo item:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7abe66353d2c86db045621ecac251949/href">https://medium.com/media/7abe66353d2c86db045621ecac251949/href</a></iframe><p>This includes the model itself, as well as a function to generate new ToDo items. Note that the guid() method is our first little morsel from Akita 😋</p><p>We also add a VISIBILITY_FILTER filters enum, which we’ll use later to filter the display of the items.</p><p>Next up is adding an Akita EntityStore:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/96739a5bc7fffbf5dab0ed56c3598bd7/href">https://medium.com/media/96739a5bc7fffbf5dab0ed56c3598bd7/href</a></iframe><p>The store is used to hold our ToDo items (the state), as well as the currently selected VISIBILITY_FILTER (aka the UI state). To read more about managing UI state with Akita check out <a href="https://engineering.datorama.com/ui-state-management-made-easy-with-akita-and-angular-6e460566ec7c">this article</a>. As you can see, very little code is needed at this stage — this is part of the charm of Akita, it saves a <em>ton</em> of boilerplate 💪</p><p>Every Akita entity store comes with a set pair of EntityQuery (for reading data from the store) and EntityService (for modifying the store). Let’s add the query first:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9ba7f4eb1209079b1ffd91c6530418b0/href">https://medium.com/media/9ba7f4eb1209079b1ffd91c6530418b0/href</a></iframe><p>Once again, Akita’s EntityQuery provides us with any basic selection functions we need (check the <a href="https://datorama.github.io/akita/docs/entities/query-entity/">docs</a> for more on that). All we need to add is a function that returns the currently selected VISIBILITY_FILTER, and one that returns the ToDo items, filtered by it. Let’s move on the service:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/decb9025ba578a03942fab0e4def37e0/href">https://medium.com/media/decb9025ba578a03942fab0e4def37e0/href</a></iframe><p>The service is also pretty lean — the basic CRUD operations are already supplied by the EntityStore, all we need to do is call them.</p><h4>The Secret Sauce: useObservable</h4><p>Starting from v.16.8.0, React provides us with a bunch of hooks that let us interact with the lifecycle directly. You can read more about React Hooks <a href="https://reactjs.org/docs/hooks-overview.html">here</a>.</p><p>I’ll import useObservable, which uses those hooks (specifically, useRef, useState, and useEffect) and a given Observable, to update a React state with its emitted values. You can read more about useObservable <a href="https://github.com/libreact/use-observable">here</a>.</p><p>Using that, with the query’s selectVisibleTodos$ method as input, gives us the last piece of the puzzle:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e1642dbffefa72eba5a92b89c673a384/href">https://medium.com/media/e1642dbffefa72eba5a92b89c673a384/href</a></iframe><p>And voilà! That’s all the ingredients we need for an efficient, DRY todo app!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fsuvnUnUgti9npIsYS9y5g.gif" /><figcaption>All this with just a pinch of React and a dash of Akita 😉</figcaption></figure><p>You can also see the full app in action here:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fstackblitz.com%2Fedit%2Freact-ts-bcg6jp%3Fembed%3D1&amp;display_name=StackBlitz&amp;url=https%3A%2F%2Fstackblitz.com%2Fedit%2Freact-ts-bcg6jp&amp;image=https%3A%2F%2Fc.staticblitz.com%2Fassets%2Ficon-03bbb9acbba813917725387f46e5df03a95d232be240e910ce5f946a973b3f86.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=stackblitz" width="745" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c956dbe951734f2872218c3fa445363/href">https://medium.com/media/3c956dbe951734f2872218c3fa445363/href</a></iframe><p><em>Follow me on </em><a href="https://medium.com/@inbalsinai"><em>Medium</em></a><em> to read more about React, Akita, and JS!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2fd077c6237c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/datorama-engineering/akita-react-hooks-a-recipe-for-sensational-state-management-2fd077c6237c">Akita + React Hooks = a Recipe for Sensational State Management</a> was originally published in <a href="https://medium.com/datorama-engineering">Datorama Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introducing Akita’s New Entity Service — At Your Service!]]></title>
            <link>https://medium.com/datorama-engineering/introducing-akitas-new-entity-service-at-your-service-c511a82fba22?source=rss-772a2245019c------2</link>
            <guid isPermaLink="false">https://medium.com/p/c511a82fba22</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[akita]]></category>
            <dc:creator><![CDATA[Inbal Sinai]]></dc:creator>
            <pubDate>Wed, 31 Jul 2019 07:50:51 GMT</pubDate>
            <atom:updated>2019-07-31T07:50:51.259Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introducing Akita’s New Entity Service — At Your Service!</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pd6WZLjeloCwF-IAwCEiMg.png" /></figure><p>Since its inception, the Akita state management solution has delivered hundreds of thousands of developers an easy, simple way to manage their application state data and ui data. The newest complementary feature to come out is Akita’s Entity Service.</p><h4>What is Akita?</h4><p>Akita is a state management pattern, built on top of RxJS, and based on OOP design principles. It saves you the hassle of creating boilerplate code and offers powerful tools with a moderate learning curve, suitable for both experienced and inexperienced developers alike.</p><h4>Why Add a Service?</h4><p>Till now, the main components of Akita were the Akita Store and the Akita Query, which both have a regular version and an Entity version. Both query and store save on a huge amount of boilerplate code, by including the most common methods needed for state management.</p><p>What we realized here in <a href="https://datorama.com/">Datorama</a> (a <a href="https://www.salesforce.com/">Salesforce</a> company), is that there’s even more boilerplate we can save you, by creating an Akita entity service, which follows the standard <a href="https://restfulapi.net/resource-naming/">RESTful naming conventions</a> by default.</p><p>Specifically, this service can be extremely useful in systems that use strict url patterns, such as CMS, admin dashboards, etc.</p><h4>Getting Started</h4><p>After <a href="https://netbasal.gitbook.io/akita/getting-started/installation">installing Akita</a>, we simply run:</p><p>npm install @datorama/akita-ng-entity-service</p><p>(or the equivalent in the package manager you use).</p><p>Let’s use <a href="https://jsonplaceholder.typicode.com/">JSONPlaceholder</a> as our REST API and quickly scaffold a feature for Posts. To get started we run:</p><p>ng g af posts</p><p>This schematics command generates an Akita PostsStore, PostsQuery, and PostsService. First we need to define the base api url that will be used for each request. This is done when adding the service configuration to the module:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cee8db37b251dfbd09455a1a282487d7/href">https://medium.com/media/cee8db37b251dfbd09455a1a282487d7/href</a></iframe><p>Note that if you have server calls that use a different base url than the one you defined in the above setting, you can modify the url per service, or use a factory if you dynamically generate the url based on other providers’ data. Our service looks like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2705497b77b8882c319ec3ca75de2fb6/href">https://medium.com/media/2705497b77b8882c319ec3ca75de2fb6/href</a></iframe><p>This ensures that the service will automatically perform its CRUD operations on the PostsStore we’ve generated. By extending NgEntityService, we get a several built-in API calls without the need to add them ourselves: get(), add(), update() and delete(). Next, let’s create a component that uses those calls:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/656ec619cb9b99fc58179042786f14c5/href">https://medium.com/media/656ec619cb9b99fc58179042786f14c5/href</a></iframe><p>As you can see, since all the tasks of initializing the requests and updating the store are all baked in to the entity service, all we need to do is call the relevant methods. Additionally, each method takes a config object where we can pass some or all of the following parameters:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/84d89e85b7bf2438401da6c1c4503492/href">https://medium.com/media/84d89e85b7bf2438401da6c1c4503492/href</a></iframe><p>The resourceName used in the urls is by default identical to the store name, but we can easily configure it. For instance, if we want our posts service to fetch its posts from the articles url we can set it in the service config:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b23337c5f87e90670c251d174974882a/href">https://medium.com/media/b23337c5f87e90670c251d174974882a/href</a></iframe><p>Alternatively, we can pass the config as the second parameter in the super() call in the service’s constructor.</p><h4>Entity Service Loader</h4><p>Loading indication is a very common scenario — we often need to display to the user an indication that the server call has been made, and our app is currently in the process of loading the resulting data.</p><p>Akita’s Entity Service comes with a built-in solution for these cases; The NgEntityServiceLoader can listen to any entity service’s built-in method and give us an indication of its loading status:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6bdca320b76e8bf9ae30c88bbf6f96eb/href">https://medium.com/media/6bdca320b76e8bf9ae30c88bbf6f96eb/href</a></iframe><p>The loaders object now contains loading indicators for each of the PostsService methods; Each one holding an Observable boolean value, indicating the method’s loading status. Thanks to that we can create customized gui in the component’s template, based on those indicators :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0335803b8bad5dbebee3d8a847758e82/href">https://medium.com/media/0335803b8bad5dbebee3d8a847758e82/href</a></iframe><p>We can also get indicators for a specific entity being updated or deleted by calling loaders.updateEntity(id) and loaders.deleteEntity(id), respectively.</p><h4>Entity Service Notifier</h4><p>In addition to that, there are cases when we need to know whether a certain operation has succeeded or failed. For example, a global component that displays toast notifications to the user.</p><p>For this purpose the Entity Service package provides the NgEntityServiceNotifier service, which we can subscribe to and get the status of any HTTP call that was made:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0f5399b1685bd3aeebca133cae2a13c8/href">https://medium.com/media/0f5399b1685bd3aeebca133cae2a13c8/href</a></iframe><p>The resulting data looks like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7b4e3be285ce18f53bed34fa353442a8/href">https://medium.com/media/7b4e3be285ce18f53bed34fa353442a8/href</a></iframe><p>The package also exposes built-in operators, which allow us to filter the type, store, and http method. For example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5f18cb519e0d6b04e41d2ed69d42b390/href">https://medium.com/media/5f18cb519e0d6b04e41d2ed69d42b390/href</a></iframe><h4>What Else is New in Akita?</h4><p>Here are a couple more Akita innovations you might have missed:</p><ul><li>Akita now features <a href="https://netbasal.gitbook.io/akita/angular-plugins/firebase-integration">integration with Firebase</a>.</li><li>In dev mode, you can now use window.$$stores and window.$$queries in your console, to obtain a reference to the stores or the queries.</li><li>The persistState plugin features a <a href="https://netbasal.gitbook.io/akita/enhancers/persist-state#performance-optimization">performance optimization</a> option.</li><li>The persistState plugin also <a href="https://netbasal.gitbook.io/akita/enhancers/persist-state#custom-hooks">supports custom hooks</a> now.</li><li>The EntityStore now has a replace method.</li><li>The PaginatorPlugin now has a refreshCurrentPage method.</li><li>The HistoryPlugin can now have a custom clear function.</li><li>The Query Entity’s selectEntity method now supports a predicate function as a parameter, i.e.: query.selectEntity(e =&gt; e.title === ‘title’).</li><li>The Query Entity can now <a href="https://netbasal.gitbook.io/akita/entity-store/entity-query/api#entity-actions">listen for a specific action</a> performed on the entities.</li><li>The StoreConfig object can take a custom deep freeze function.</li></ul><p>Want to learn more about Akita? Check out these articles:</p><ul><li><a href="https://engineering.datorama.com/10-reasons-why-you-should-start-using-akita-as-your-state-management-solution-66b63d033fec">10  Reasons Why You Should Start Using Akita as Your State Management Solution</a></li><li><a href="https://netbasal.gitbook.io/akita/">Introduction</a></li><li><a href="https://hackernoon.com/lets-build-a-pizza-store-with-akita-state-management-for-angular-applications-de6ced65024d">Let&#39;s Build a Pizza Store with Akita - State Management for Angular Applications</a></li></ul><p><em>Follow me on </em><a href="https://medium.com/@inbalsinai"><em>Medium</em></a><em> to read more about Angular, Akita, JS!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c511a82fba22" width="1" height="1" alt=""><hr><p><a href="https://medium.com/datorama-engineering/introducing-akitas-new-entity-service-at-your-service-c511a82fba22">Introducing Akita’s New Entity Service — At Your Service!</a> was originally published in <a href="https://medium.com/datorama-engineering">Datorama Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Supercharge Your Svelte State Management with Akita]]></title>
            <link>https://medium.com/@inbalsinai/supercharge-your-svelte-state-management-with-akita-f1f9de5ef43d?source=rss-772a2245019c------2</link>
            <guid isPermaLink="false">https://medium.com/p/f1f9de5ef43d</guid>
            <category><![CDATA[akita]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[svelte]]></category>
            <category><![CDATA[sveltejs]]></category>
            <dc:creator><![CDATA[Inbal Sinai]]></dc:creator>
            <pubDate>Tue, 02 Jul 2019 12:13:42 GMT</pubDate>
            <atom:updated>2019-07-03T10:32:54.815Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OJanbeH00q02SdV2-KJ9ug.png" /></figure><p>There’s a new player in the world of JS frameworks — Svelte. As its name suggests, Svelte is lean, extremely lean. In fact, Svelte’s modus operandi, of compiling code to (ideal) vanilla js during the build phase rather than interpreting it during the run phase, has had people describing it as a non-framework and its own creator <a href="https://gist.github.com/Rich-Harris/0f910048478c2a6505d1c32185b61934">calling it a language</a>, rather than a framework. Specifically, one created for describing reactive user interfaces.</p><p>I’ve started playing around with Svelte and so far I’ve been having a blast. The <a href="https://svelte.dev/tutorial">tutorial</a> offered by creator Rich Harris functions as a very pleasant introduction. After completing it, I started to wonder how <a href="https://netbasal.com/introducing-akita-a-new-state-management-pattern-for-angular-applications-f2f0fab5a8">Akita</a>, the state management solution we’ve created here in Datorama, would work in conjunction with Svelte.</p><h4>Svelte + Akita = A Great Combo</h4><p>If you’re already familiar with Svelte, you might be asking yourself why additional state management is even required, as Svelte comes with built-in reactive store functionality. If you have a small application, you can probably get away with using Svelte API alone. However, larger and more complex applications require a full-fledged state management solution. It’s similar to how we need Redux when we have React’s Context API.</p><p>A note on Akita’s architecture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0K-zz1VPZD6RlsSY8a8fCA.png" /></figure><p>The two main components of Akita are the store and the query. You can think of the store like a table that contains data in a database, and you can perform various actions on it like inserting, updating, etc. My svelte component will reactively get the data from the query. And since I want it to remain agnostic of its data source, I won’t import the store inside the component; Instead, I’ll create a service for the component to work with.</p><p>As you can see, Akita defines a strict pattern for managing your state data. It comes with powerful Entity management, a robust set of plugins and dev-tools, and its own cli. Svelte and Akita are a great natural combo because Akita’s queries can return observables, which Svelte <strong>supports out of the box</strong>. So here is one example of how the two can be used in tandem:</p><h4>Incorporating Akita</h4><p>To add Akita to my svelte app, I install it, and its cli, via npm. I start with a fresh <a href="https://github.com/antony/svelte-seed">Svelte seed</a> and go ahead with creating the traditional “TODO” app using Svelte and Akita.</p><h4>The TODO Entity Store</h4><p>Since we’re dealing with TODO items, I opt to create an Entity Store in Akita. You can think of an entity store as a table in a database where each row represents an entity. To do that I use the <a href="https://github.com/datorama/akita/tree/master/cli">Akita CLI</a>.</p><p>The store itself has all the built-in methods I need in order to perform CRUD operations on my entities.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ba3c48ce9f796035143f3ec978c9387e/href">https://medium.com/media/ba3c48ce9f796035143f3ec978c9387e/href</a></iframe><p>In addition to those methods, I add a filter parameter in the store creation, representing the <a href="https://engineering.datorama.com/ui-state-management-made-easy-with-akita-and-angular-6e460566ec7c">UI State data</a> used to filter the display of the TODO items.</p><h4>The TODO Service</h4><p>Next, I’ll create the aforementioned service:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e4f290154d3d9e6d04b5e927e2d8684a/href">https://medium.com/media/e4f290154d3d9e6d04b5e927e2d8684a/href</a></iframe><p>It contains all the methods I’ll need to update/read from the server and the store.</p><h4>The TODO Entity Query</h4><p>Akita Entity Query’s built-in methods can be divided into two types. A method that starts with select, for which you get an observable for the requested data, and methods that start with get, in which you get the requested data directly. It’s important to emphasize that the subscription won’t be triggered unless the value you asked is changed by reference. To those, I add the following methods:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a516a995648f1afc6b2e0e6295ff09d2/href">https://medium.com/media/a516a995648f1afc6b2e0e6295ff09d2/href</a></iframe><p>I use combineLatest to subscribe to the store, get the latest version of the TODO list, and filter it according to the latest filter selection.</p><p>The next step is to create the Svelte components that interact with the Akita Entity store:</p><h4>The Filter Component</h4><p>This component’s sole responsibility is to let the users determine the criteria by which they filter the TODO list:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/116b7ae4bed2c19bb2346b51752f568e/href">https://medium.com/media/116b7ae4bed2c19bb2346b51752f568e/href</a></iframe><h4>The Add TODO Component</h4><p>This component is in charge of dispatching a todo event for the purpose of adding a TODO:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/317af92d239c9e63d8f9fb2f4921760b/href">https://medium.com/media/317af92d239c9e63d8f9fb2f4921760b/href</a></iframe><h4>The TODO Component</h4><p>It is used to display a single TODO item, along with a button for deleting it, and a checkbox to toggle its ‘completed’ status:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/46110575cafd08261c4622a328de5020/href">https://medium.com/media/46110575cafd08261c4622a328de5020/href</a></iframe><h4>Connecting the Dots</h4><p>Finally, a TODOs component will use all the previously mentioned components, along with the query and service I’ve created, to manage my list:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b6ffabb2ab447d3e9166118c6471e79f/href">https://medium.com/media/b6ffabb2ab447d3e9166118c6471e79f/href</a></iframe><h4>The End Result</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zf2vKodscNUR1-ETxENxkA.gif" /></figure><p>Before we conclude, I wanted to add one last tidbit: Another thing you can get from Akita out of the box, is the ability to persist the state via local storage. I simply add in the main JS file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/439a7cb0d4ea70b0ea892d7d9d8576cf/href">https://medium.com/media/439a7cb0d4ea70b0ea892d7d9d8576cf/href</a></iframe><p>And voila, your state is now persistent!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*AI4OxkMq8gXqawiWyYq3QQ.gif" /></figure><p>You can find all the files for this example <a href="https://github.com/datorama/akita/tree/master/examples/svelte">here</a>.</p><p>In summary: <strong>Both Akita and Svelte offer a moderate learning curve and enable the easy creation of incredibly lean apps with super-efficient state management out of the box. I encourage you to try both, either together or separately 👯‍♀️</strong></p><p>Here are some more articles about Akita:</p><ul><li><a href="https://engineering.datorama.com/10-reasons-why-you-should-start-using-akita-as-your-state-management-solution-66b63d033fec">10  Reasons Why You Should Start Using Akita as Your State Management Solution</a></li><li><a href="https://netbasal.gitbook.io/akita/">Introduction</a></li></ul><p><em>Follow me on </em><a href="https://medium.com/@inbalsinai"><em>Medium</em></a><em> to read more about Svelte, Akita, JS!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f1f9de5ef43d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Manage Your State Navigation Data with a Breeze Using Angular and Akita]]></title>
            <link>https://medium.com/better-programming/manage-your-state-navigation-data-with-a-breeze-using-angular-and-akita-5c90ce15ba9b?source=rss-772a2245019c------2</link>
            <guid isPermaLink="false">https://medium.com/p/5c90ce15ba9b</guid>
            <category><![CDATA[akita]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Inbal Sinai]]></dc:creator>
            <pubDate>Thu, 27 Jun 2019 15:44:52 GMT</pubDate>
            <atom:updated>2019-06-28T21:48:34.943Z</atom:updated>
            <content:encoded><![CDATA[<h3>Managing Your State Navigation Data is a Breeze Using Angular and Akita</h3><h4>A neat package offered to Akita users</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fGyVcN1kwU524mqKM_xrCg.png" /></figure><p>The <a href="https://github.com/datorama/akita-ng-router-store">Akita ng-router-store</a> is a neat package offered to Akita users, which enables binding the Angular router state to an Akita store. The benefits of this approach are:</p><ul><li>The router state is stored in an Akita store named router, which serves as the single source of truth for things such as URL, state data parameters, query parameters, etc.</li><li>Our components don’t have to be familiar with the data source. The RouterQuery can be injected in any one of the queries to create an encapsulated derived selector.</li><li>The library exposes Akita style queries, saving you from dealing with all the required boilerplate code.</li><li>We can examine the current router state in the Redux devtools and perform ‘time-traveling’.</li></ul><p>To get started, install the package and add it, as well as Akita’s devtools module, to the app module:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1b0547f2da882018cd8475a6e18f2fc5/href">https://medium.com/media/1b0547f2da882018cd8475a6e18f2fc5/href</a></iframe><p>At this point you should see the router store in the Redux devtools, and you have at your disposal the following query API:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2c4c805e2166ed37c3e57bb6496a7fdb/href">https://medium.com/media/2c4c805e2166ed37c3e57bb6496a7fdb/href</a></iframe><p>For example, let’s say we want to query the current entity based on the URL id parameter, we can do the following in our ArticlesQuery class:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d30d7a5057ba3dc606e09a53d5dd9e43/href">https://medium.com/media/d30d7a5057ba3dc606e09a53d5dd9e43/href</a></iframe><p>And use it in our component:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/55d44aebbcaf0017c283e05d17167cfd/href">https://medium.com/media/55d44aebbcaf0017c283e05d17167cfd/href</a></iframe><p>Voila — easy breezy navigation management!</p><p>Last but not least: A new version of Akita just landed in Github! You can check out the breaking changes and the new features <a href="https://github.com/datorama/akita/blob/master/BREAKING_CHANGES.md#400">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5c90ce15ba9b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/manage-your-state-navigation-data-with-a-breeze-using-angular-and-akita-5c90ce15ba9b">Manage Your State Navigation Data with a Breeze Using Angular and Akita</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[10  Reasons Why You Should Start Using Akita as Your State Management Solution]]></title>
            <link>https://medium.com/datorama-engineering/10-reasons-why-you-should-start-using-akita-as-your-state-management-solution-66b63d033fec?source=rss-772a2245019c------2</link>
            <guid isPermaLink="false">https://medium.com/p/66b63d033fec</guid>
            <category><![CDATA[akita]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[svelte]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[vue]]></category>
            <dc:creator><![CDATA[Inbal Sinai]]></dc:creator>
            <pubDate>Thu, 23 May 2019 09:05:36 GMT</pubDate>
            <atom:updated>2019-05-23T09:05:36.386Z</atom:updated>
            <content:encoded><![CDATA[<h3>10 Reasons Why You Should Start Using Akita as Your State Management Solution</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*18sWXi19o9nN7PqC-CpniQ.png" /></figure><p>State management is ubiquitous in web applications, be they big or small. One of the notable solutions in this field is Akita. Whether it’s entities arriving from the server or UI state data, Akita has custom-built stores, powerful tools, and tailor-made plugins, which help you manage the data and negate the need for massive amounts of boilerplate code. Here are ten reasons why you should start using it:</p><ol><li><strong>Akita is a veteran in the field</strong>: It’s been out for a year already and even before that it was used for over a year in Datorama, as part of a real-world app utilized by thousands of customers. The app includes elaborate state management, component communication, complex form handling, dirty checking, undo functionality, and rapid manipulation of big data.</li><li><strong>Akita has the backing of Datorama:</strong> Akita doesn’t rely on sponsors to continue evolving. It was created here, in Datorama, a Salesforce company. Datorama developers maintain it and improve it as part of our work schedule. Additionally, we often get inspiration for new Akita features from the needs of the continually growing and evolving Datorama app.</li><li><strong>Akita is easy to pick up: </strong>It has a moderate learning curve, suitable for both experienced and inexperienced developers alike. It features a robust set of tools, anything you might need for quickly deploying a quality app.</li><li><strong>Akita isn’t coupled with Angular:</strong> Once you get the hang of using it, Akita can be used with <a href="https://engineering.datorama.com/oop-and-rxjs-managing-state-in-react-with-akita-de981e09307">React</a>, Vue, <a href="https://github.com/datorama/akita/tree/master/examples/svelte">Svelte</a>, Angular, or even vanilla JS. No framework-specific adapter is needed; This means that if you swap framework, changes to Akita code are kept to a minimum.</li><li><strong>Akita has a 0 bugs policy: </strong>Here at Datorama, we consider your bugs as our bugs. Since Akita is deployed in our production environment, it’s crucial for us to solve any bugs you might discover ASAP. The Akita repo issues section is a testament to that.</li><li><strong>Akita is very well documented: </strong>We understand the importance of thorough documentation, and do our best to supply Akita users with complete documentation of all necessary information. Additionally, we often write <a href="https://netbasal.gitbook.io/akita/general/blog-posts">blog posts</a> detailing the various ways in which Akita can be used in your apps. Like Akita itself, we constantly work on growing and improving this knowledge base.</li><li><strong>Akita’s community is growing, fast: </strong>With over <a href="https://npm-stat.com/charts.html?package=%40datorama%2Fakita">320,000 downloads</a> to date, Akita is growing in popularity in lightning speed. Another sign of its ubiquity — familiarity with Akita has recently started showing up in Front-End position postings.</li><li><strong>Akita is well-suited for full stack developers: </strong>Akita is based on object-oriented design principles rather than functional programming, so developers with OOP experience should feel right at home.</li><li><strong>Akita developers are easy to reach: </strong>Akita has a dedicated Gitter channel which is staffed daily.</li><li><strong>Akita has a full suite of accompanying plugins: </strong>redo-undo, persist state, dirty check, pagination, devtools, router integration, CLI, and more. <br>See something missing that you want to be added? We’re very receptive to requests 🙂</li></ol><p>In summary:<strong> There are plenty of reasons to pick up Akita today. I highly recommend you give it a try — you’ll discover it provides you with an efficient and easy to use solution for all your state management needs! To get started go to the </strong><a href="https://github.com/datorama/akita"><strong>Akita repo on github</strong></a><strong>.</strong></p><p><em>Follow me on </em><a href="https://medium.com/@inbalsinai"><em>Medium</em></a><em> to read more about Angular, Akita, JS!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=66b63d033fec" width="1" height="1" alt=""><hr><p><a href="https://medium.com/datorama-engineering/10-reasons-why-you-should-start-using-akita-as-your-state-management-solution-66b63d033fec">10  Reasons Why You Should Start Using Akita as Your State Management Solution</a> was originally published in <a href="https://medium.com/datorama-engineering">Datorama Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Timers for Asynchronous Polling Operations — the Good, the Bad and the Ugly]]></title>
            <link>https://medium.com/@inbalsinai/timers-for-asynchronous-polling-operations-the-good-the-bad-and-the-ugly-b446a018725a?source=rss-772a2245019c------2</link>
            <guid isPermaLink="false">https://medium.com/p/b446a018725a</guid>
            <category><![CDATA[rxjs]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Inbal Sinai]]></dc:creator>
            <pubDate>Mon, 29 Apr 2019 14:04:03 GMT</pubDate>
            <atom:updated>2019-04-29T14:04:03.616Z</atom:updated>
            <content:encoded><![CDATA[<h3>Timers for Asynchronous Polling Operations — the Good, the Bad and the Ugly</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rn5tUbcd08Jhk81WHJzKCw.jpeg" /><figcaption>When you have to poll, poll. Don’t talk.</figcaption></figure><p>When creating web applications we sometimes come across the need to perform a certain operation repeatedly over time, with a set period of time between runs. The most common example is when we need to poll a server for data.</p><h4>The Bad: setInterval</h4><p>While the initial inclination might be to use setInterval for such cases — after all, it seems made for the task, and setting it would take a single line of code — however, this is not advised if the operation in question is asynchronous. This is because we cannot control when the asynchronous operation concludes, and as a result multiple operations might run simultaneously and their results might not arrive in the correct order:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fstackblitz.com%2Fedit%2Fasync-polling-setinterval%3Fembed%3D1&amp;url=https%3A%2F%2Fstackblitz.com%2Fedit%2Fasync-polling-setinterval&amp;image=https%3A%2F%2Fc.staticblitz.com%2Fassets%2Ficon-664493542621427cc8adae5e8f50d632f87aaa6ea1ce5b01e9a3d05b57940a9f.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=stackblitz" width="745" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/fdb19c66749afcfe919e4eabe66b7a28/href">https://medium.com/media/fdb19c66749afcfe919e4eabe66b7a28/href</a></iframe><h4>The Ugly: setTimeout</h4><p>Instead, we want to ensure that the periodic delay initiates only when the operation concludes. The tried-and-true method that’s used in these cases is to call setTimeout with the operation, and in the asynchronous callback method repeat the setTimeout call:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fstackblitz.com%2Fedit%2Fasync-polling-settimeout%3Fembed%3D1&amp;url=https%3A%2F%2Fstackblitz.com%2Fedit%2Fasync-polling-settimeout&amp;image=https%3A%2F%2Fc.staticblitz.com%2Fassets%2Ficon-664493542621427cc8adae5e8f50d632f87aaa6ea1ce5b01e9a3d05b57940a9f.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=stackblitz" width="745" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/50297e63b4dbbfc9118f04679cb7c2a5/href">https://medium.com/media/50297e63b4dbbfc9118f04679cb7c2a5/href</a></iframe><h4>The Good: RxJS Timer/concatMap combo</h4><p>However the good people at RxJS have a more elegant solution — if you use the <a href="https://www.learnrxjs.io/operators/creation/timer.html">RxJS timer</a> in conjunction with the <a href="https://www.learnrxjs.io/operators/transformation/concatmap.html">RxJS concatMap</a>, we get the desired result. This is because the concatMap subscribes to the inner observables returned by the getData method in the order they were called, and emits them in that order. In fact, it doesn’t subscribe to the next observable until the previous one completes. This ensures behind the scenes that the delay isn’t initiated until the operation of that cycle concludes, guaranteeing that successive operations remain separated and do not coincide:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fstackblitz.com%2Fedit%2Fasync-polling-rxjs%3Fembed%3D1&amp;url=https%3A%2F%2Fstackblitz.com%2Fedit%2Fasync-polling-rxjs&amp;image=https%3A%2F%2Fc.staticblitz.com%2Fassets%2Ficon-664493542621427cc8adae5e8f50d632f87aaa6ea1ce5b01e9a3d05b57940a9f.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=stackblitz" width="745" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/a1b8c6968751b3728c1a647f7385935a/href">https://medium.com/media/a1b8c6968751b3728c1a647f7385935a/href</a></iframe><p><em>Follow me on </em><a href="https://medium.com/@inbalsinai"><em>Medium</em></a><em> to read more about Angular, Akita, JS!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b446a018725a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Form Fatale: How Akita’s Form Manager Can Do Away with Complex Multistep Form Logic in Angular]]></title>
            <link>https://medium.com/@inbalsinai/form-fatale-how-akitas-form-manager-can-do-away-with-complex-multistep-form-logic-in-angular-329a557cc68?source=rss-772a2245019c------2</link>
            <guid isPermaLink="false">https://medium.com/p/329a557cc68</guid>
            <category><![CDATA[akita]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Inbal Sinai]]></dc:creator>
            <pubDate>Wed, 20 Mar 2019 19:37:15 GMT</pubDate>
            <atom:updated>2019-03-20T19:37:15.792Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iONMHxxG0U093e4z5hY1hA.png" /></figure><p>When it comes to maintaining a multistep form in your application, it can turn into quite a big headache, as any step or combination of steps can affect others, and you need to have real-time knowledge of both the form’s overall validity as well as each step’s status.</p><p>But not when you have Akita! Apart from being one of the leading state management libraries, with over 240K downloads to date, Akita has an additional library, AkitaNgFormsManager, which offers form-specific functionality that can significantly simplify your form management experience.</p><p>The AkitaNgFormsManager lets you sync Angular’s formGroup, formControl, and formArray, via a unique store created for that purpose. The store will hold the controls&#39; data such as values, validity, pristine status, errors, etc. Unlike other libraries, this form manager doesn’t require the user to learn a brand new API; Instead, it relies on the existing Angular forms API.</p><p>Let’s take a look at a multi-step form and see how we can use AkitaNgFormsManager with it and what benefits we get from that. We won’t use the entire library API, but you can read about all the available methods <a href="https://netbasal.gitbook.io/akita/angular-plugins/angular-forms-manager">here</a>.</p><h4>Form Value Persistence via a Single API Call</h4><p>For this example we create a form with three steps; The first will ask for the user’s name and email, the second for details in the user’s address, and the third will ask for the user’s children’s names. We store each step in our AkitaNgFormsManager store separately, by using the library’s upsert method.</p><p>Here’s how the form management looks like when we inspect the store in Redux DevTools:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PywvolsFnQ3ZASI2wx6kpQ.gif" /></figure><p>Step one:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f4a91875c1156066da0f1c6a0a42f667/href">https://medium.com/media/f4a91875c1156066da0f1c6a0a42f667/href</a></iframe><p>Step two:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cb16a94404f27ee6c4a27192350c877d/href">https://medium.com/media/cb16a94404f27ee6c4a27192350c877d/href</a></iframe><p>Step three:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b3e8d12ca647ab849aa5273d6a9f2b89/href">https://medium.com/media/b3e8d12ca647ab849aa5273d6a9f2b89/href</a></iframe><p>This isn’t your regular run-of-the-mill upsert method —it inserts the form in AkitaNgFormsManager’s store if a form by that name doesn’t already exist for the given key, but if it does, it updates the component’s newly created form with the values and fields already stored for the existing form. This ensures that the changes made in each form are preserved even as we leave that form and the component in charge of it is destroyed. And it does that in a single, elegant, API call.</p><p>The component in charge of the third step is a bit more clever than a regular form: it adds and removes form fields dynamically, based on the selected number of children. To ensure that the modified FormArray can be recreated the next time the component is initialised, we add a third config parameter in the upsert call, containing a factory function for generating each FormControl in the array. This ensures that upon ensuing visits to the form page, the correct number of fields will be generated based on the form saved in the store.</p><h4>Tracking Validity via the Store</h4><p>To keep track of each step’s validity and dirty status we create a directive, ValidStepDirective:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f1ef84ee00e1b89fff558f9cd26fc67c/href">https://medium.com/media/f1ef84ee00e1b89fff558f9cd26fc67c/href</a></iframe><p>The directive receives as input the form’s key in the store, allowing it to simply observe the required form status values (using the combineLatest operator). In this case, we combine the two values and return false if and only if the form is both dirty and invalid. The result controls whether the host element receives the “invalid” class, allowing us to signal to the user which step is invalid.</p><h4>Accessing Form Values via the Store</h4><p>The parent component also requires each step’s validity status for an additional reason: Since these are all steps of a single form, the parent component, OnBoardingComponent, holds the single submission button for the entire form, enabled only when all steps are valid:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5ba0c47acb80e88bc50a4fc3fb4b51d5/href">https://medium.com/media/5ba0c47acb80e88bc50a4fc3fb4b51d5/href</a></iframe><p>Once again, simply by accessing the store, OnBoardingComponent can easily determine the overall validity of the form at any given moment. And upon submission, it gets each step’s form value from the store in order to submit it to the server (or in our example’s case, log it in the console).</p><p>Here’s the end result:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fstackblitz.com%2Fedit%2Fakita-multistep-form%3Fembed%3D1&amp;url=https%3A%2F%2Fstackblitz.com%2Fedit%2Fakita-multistep-form&amp;image=https%3A%2F%2Fc.staticblitz.com%2Fassets%2Ficon-664493542621427cc8adae5e8f50d632f87aaa6ea1ce5b01e9a3d05b57940a9f.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=stackblitz" width="745" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/4b538d8127bbb47c11fd398bd7388f2e/href">https://medium.com/media/4b538d8127bbb47c11fd398bd7388f2e/href</a></iframe><p>In summary: <strong>Managing the state of complex, multi-step forms, has never been easier. AkitaNgFormsManager takes care of all the boilerplate needed to consistently deliver each step’s values, as well as track its validity and dirty status.</strong></p><p>Here are some more articles about Akita:</p><ul><li><a href="https://hackernoon.com/lets-build-a-pizza-store-with-akita-state-management-for-angular-applications-de6ced65024d">Let&#39;s Build a Pizza Store with Akita - State Management for Angular Applications</a></li><li><a href="https://netbasal.com/akita-and-firebase-a-match-made-in-angular-heaven-4a47ff889208">Akita and Firebase — a Match Made in Angular Heaven</a></li><li><a href="https://netbasal.com/infinite-scroll-in-angular-using-akita-c5edf51de4ed">Infinite Scroll in Angular Using Akita</a></li></ul><p><em>Follow me on </em><a href="https://medium.com/@inbalsinai"><em>Medium</em></a><em> to read more about Angular, Akita, JS!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=329a557cc68" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Supercharge Your Akita for Angular by Using Mediators]]></title>
            <link>https://medium.com/@inbalsinai/supercharge-your-akita-for-angular-by-using-mediators-d84b9fa951a1?source=rss-772a2245019c------2</link>
            <guid isPermaLink="false">https://medium.com/p/d84b9fa951a1</guid>
            <category><![CDATA[akita]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Inbal Sinai]]></dc:creator>
            <pubDate>Mon, 18 Feb 2019 15:43:43 GMT</pubDate>
            <atom:updated>2019-02-20T21:17:01.731Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FFgBa4jyWtoEoYpT17gDpQ.png" /></figure><p><a href="https://engineering.datorama.com/good-things-come-to-those-who-wait-whats-new-in-akita-v2-d7d98e6476f0">Akita continues to evolve and attract more users</a>, and while using it is pretty simple and straightforward, there are ways where Akita can become even more efficient and useful to us. One such way is implementing the mediator pattern by combining multiple Queries and/or Stores.</p><p>Even the most casual Akita users are familiar with the Query. It’s a class used to query the Akita Store, which functions similarly to database queries. Its constructor function receives as parameters its own store or other query classes. This last part is where it gets interesting: By combining them, we can use one Query to query multiple Stores, which can be ideal in some cases.</p><h4><strong>Combining Queries</strong></h4><p>Say we have an app offering themes, games and ringtones to our users. Naturally since these entities are inherently different we create a Store for each. But in the overall app we need to query all three stores in order to display the contents side-by-side.</p><p>Rather than querying each at a time, a more elegant solution would be to create an overarching Query, which contains each store’s EntityQuery:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/94b802b3f37a89913078657ff3baa810/href">https://medium.com/media/94b802b3f37a89913078657ff3baa810/href</a></iframe><h4>Combining Stores</h4><p>Similarly, we can create an overarching Store, which includes references to the three Entity Stores:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1d7f8dc93cb86cc84fb74a844050e620/href">https://medium.com/media/1d7f8dc93cb86cc84fb74a844050e620/href</a></iframe><p>And based on that store, we can create a Service, that can interact with all three stores at once, or any individual store:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/85fdf956feaa2764ec54c23ee6c20e73/href">https://medium.com/media/85fdf956feaa2764ec54c23ee6c20e73/href</a></iframe><h4>End Result</h4><p>Finally, we can use our new Query and Service in components which require this type of “big-picture” data:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a9067962f571e7c0f8a892ab00e3db2e/href">https://medium.com/media/a9067962f571e7c0f8a892ab00e3db2e/href</a></iframe><p>In summary: <strong>In components which require access to multiple stores, consider creating mediators which combine the stores and their respective queries to keep your code DRY and make it more elegant.</strong></p><p><em>Follow me on </em><a href="https://medium.com/@inbalsinai"><em>Medium</em></a><em> to read more about Angular, Akita, JS!</em></p><figure><a href="https://usejournal.com/?utm_source=medium.com&amp;utm_medium=noteworthy_blog&amp;utm_campaign=guest_post_image"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f2IVAl0TbsfES9cFGYr40g.png" /></a></figure><p>📝 Read this story later in <a href="https://usejournal.com/?utm_source=medium.com&amp;utm_medium=noteworthy_blog&amp;utm_campaign=guest_post_read_later_text">Journal</a>.</p><p>🗞 Wake up every Sunday morning to the week’s most noteworthy Tech stories, opinions, and news waiting in your inbox: <a href="https://usejournal.com/newsletter/?utm_source=medium.com&amp;utm_medium=noteworthy_blog&amp;utm_campaign=guest_post_text">Get the noteworthy newsletter &gt;</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d84b9fa951a1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>