<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ngxs</title>
    <description>The latest articles on DEV Community by Ngxs (@ngxs).</description>
    <link>https://dev.to/ngxs</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F1428%2Fce93574c-5522-4585-9c4d-b5ce25e669bd.png</url>
      <title>DEV Community: Ngxs</title>
      <link>https://dev.to/ngxs</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ngxs"/>
    <language>en</language>
    <item>
      <title>Announcing NGXS 3.7</title>
      <dc:creator>markwhitfeld</dc:creator>
      <pubDate>Wed, 09 Sep 2020 07:06:35 +0000</pubDate>
      <link>https://dev.to/ngxs/announcing-ngxs-3-7-1kbk</link>
      <guid>https://dev.to/ngxs/announcing-ngxs-3-7-1kbk</guid>
      <description>&lt;p&gt;2020 has definitely been a year of ups and downs! As open source maintainers, the shock out of normality has definitely brought its challenges... with work invading the home, family invading work, and every last drop of our day being caught up in the chaos.&lt;/p&gt;

&lt;p&gt;This update has been a long time in the making, with lengthy discussions around each new feature, and great efforts to ensure the stability and backward compatibility of the library and API, following the big changes in Angular and in TypeScript this year.&lt;/p&gt;

&lt;p&gt;Thank you to our incredible community for your ongoing contributions, enthusiasm, and support!&lt;/p&gt;

&lt;p&gt;Now, let's get to the release...&lt;/p&gt;

&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;🚀 Official Angular 10 Support&lt;/li&gt;
&lt;li&gt;🛑 Improved Error Messages&lt;/li&gt;
&lt;li&gt;🐛 Bug Fixes&lt;/li&gt;
&lt;li&gt;🔌 Plugin Improvements and Fixes&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Official Angular 10 Support
&lt;/h2&gt;

&lt;p&gt;Angular 10 brought many behind the scenes improvements to the library we all know and love. Updates to the underlying tooling, upgrades to versions of library dependencies (TypeScript, etc.), and further improvements to Ivy and bundle sizes.&lt;/p&gt;

&lt;p&gt;The day that Angular 10 was released, we were ready to announce to the world that we fully supported the new version... but alas we discovered that Angular 10 had &lt;a href="https://github.com/angular/angular/issues/35265#issuecomment-682123303" rel="noopener noreferrer"&gt;issues with HMR&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;The &lt;code&gt;@ngxs/store&lt;/code&gt; library and all of the other plugins supported Angular 10 out of the box, but the HMR plugin was not so lucky. Our commitment to the stability of the library extends to all of the core plugins, including the HMR plugin.&lt;/p&gt;

&lt;p&gt;We tried to work around the issue, but unfortunately, there was nothing we could do and the issue wasn't receiving much attention from the Angular team. As a result, we have decided to deprecate the HRM plugin. More on this later...&lt;/p&gt;

&lt;h2&gt;
  
  
  Improved Error Messages
&lt;/h2&gt;

&lt;p&gt;Sometimes a developer can miss something small in their app that can result in obtuse and hard to debug issues. We have improved some of our error detection and messaging in order to give better feedback to the developer about where they may have gone wrong.&lt;/p&gt;

&lt;p&gt;Here are some of the scenarios that we covered:&lt;/p&gt;

&lt;h3&gt;
  
  
  Empty &lt;code&gt;type&lt;/code&gt; Property on Action &lt;a href="https://github.com/ngxs/store/pull/1625" rel="noopener noreferrer"&gt;(PR #1625)&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;For example, if you define an action that has a &lt;code&gt;type&lt;/code&gt; property but its value is not set, then typescript is happy and the app compiles, but the action handlers cannot correctly determine the type of action. &lt;/p&gt;

&lt;p&gt;Now you will receive a convenient message notifying you of the action that has an empty &lt;code&gt;type&lt;/code&gt; property.&lt;/p&gt;

&lt;h3&gt;
  
  
  Incorrect Arguments for &lt;code&gt;ofAction*&lt;/code&gt; operator &lt;a href="https://github.com/ngxs/store/pull/1616" rel="noopener noreferrer"&gt;(PR #1616)&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;ofAction*&lt;/code&gt; pipeable operators previously had a pretty open typings for the argument definition. We have improved this typing so that it only accepts valid action types.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bug Fixes
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Relax &lt;code&gt;@Select&lt;/code&gt; type check &lt;a href="https://github.com/ngxs/store/pull/1623" rel="noopener noreferrer"&gt;(PR #1623)&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;In NGXS v3.6 we added a typescript trick that would show an error if the declared type of the variable decorated by the &lt;code&gt;@Select&lt;/code&gt; decorator didn't match the type of the selector referenced by the decorator. Unfortunately, this prevented the use of this decorator with &lt;code&gt;private&lt;/code&gt; or &lt;code&gt;protected&lt;/code&gt; fields. Due to this being a regression over NGXS v3.5, we reverted this change.&lt;/p&gt;

&lt;h3&gt;
  
  
  Handle Empty Observables Correctly &lt;a href="https://github.com/ngxs/store/pull/1615" rel="noopener noreferrer"&gt;(PR #1615)&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Previously, if an observable returned from an &lt;code&gt;@Action&lt;/code&gt; function completed without emitting any values then this would be seen as a cancellation. This type of returned observable is entirely valid, and therefore we adjusted the internal processing of observables to accept an empty observable as a valid completion scenario.&lt;/p&gt;

&lt;h2&gt;
  
  
  Plugin Improvements
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Logger Plugin
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Feature: Action Filter in Logger Plugin &lt;a href="https://github.com/ngxs/store/pull/1571" rel="noopener noreferrer"&gt;(PR #1571)&lt;/a&gt;
&lt;/h4&gt;

&lt;p&gt;The logger plugin did not have an option to ignore specific actions. It either logged every action or, when disabled, did not log any action at all. However, you may need logging actions conditionally because of several reasons like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Some actions are not your focus and logging them as well makes it hard to find what you are actually working on.&lt;/li&gt;
&lt;li&gt;Some actions are simply fired too often and the console becomes cumbersome.&lt;/li&gt;
&lt;li&gt;You want to log an action only when there is a certain state.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With this version, the &lt;code&gt;forRoot&lt;/code&gt; method of the &lt;code&gt;NgxsLoggerPluginModule&lt;/code&gt; takes a &lt;code&gt;filter&lt;/code&gt; option, which is a predicate that defines the actions to be logged. Here is a simple example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;NgxsModule&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;getActionTypeFromInstance&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@ngxs/store&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;NgxsLoggerPluginModule&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@ngxs/logger-plugin&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;SomeAction&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./path/to/some/action&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;NgModule&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;imports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="nx"&gt;NgxsModule&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forRoot&lt;/span&gt;&lt;span class="p"&gt;([]),&lt;/span&gt;
    &lt;span class="nx"&gt;NgxsLoggerPluginModule&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forRoot&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;action&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;getActionTypeFromInstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;action&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="nx"&gt;SomeAction&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;type&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AppModule&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the &lt;code&gt;SomeAction&lt;/code&gt; action will not be logged, because the predicate returns &lt;code&gt;false&lt;/code&gt; for it. You may pass more complicated prediactes if you want and even make use of current state snapshot in your predicates:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;NgxsModule&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;getActionTypeFromInstance&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@ngxs/store&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;NgxsLoggerPluginModule&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@ngxs/logger-plugin&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;SomeAction&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./path/to/some/action&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;NgModule&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;imports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="nx"&gt;NgxsModule&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forRoot&lt;/span&gt;&lt;span class="p"&gt;([]),&lt;/span&gt;
    &lt;span class="nx"&gt;NgxsLoggerPluginModule&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forRoot&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;action&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
        &lt;span class="nf"&gt;getActionTypeFromInstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;action&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;SomeAction&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;foo&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;bar&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AppModule&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The predicate given in this example lets you log only &lt;code&gt;SomeAction&lt;/code&gt; and only when &lt;code&gt;foo&lt;/code&gt; state is equal to &lt;code&gt;'bar'&lt;/code&gt;. This makes it easier to pinpoint a dispatched action while debugging it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Important Note:&lt;/strong&gt; The predicate will be called for every action. This may cause performance issues in development, especially when you are planning to keep the predicate after debugging. Therefore, please consider using a memoized function for filters more complicated than a simple action comparison. You may take advantage of memoization libraries for that.&lt;/p&gt;

&lt;h3&gt;
  
  
  Storage Plugin
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Feature: Serialization Interceptors in Storage Plugin &lt;a href="https://github.com/ngxs/store/pull/1513" rel="noopener noreferrer"&gt;(PR #1513)&lt;/a&gt;
&lt;/h4&gt;

&lt;p&gt;You can define your own logic before or after the state get serialized or deserialized.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;beforeSerialize: Use this option to alter the state before it gets serialized.&lt;/li&gt;
&lt;li&gt;afterSerialize: Use this option to alter the state after it gets deserialized. For instance, you can use it to instantiate a concrete class.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;NgModule&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;imports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="nx"&gt;NgxsStoragePluginModule&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forRoot&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;counter&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;beforeSerialize&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;counter&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="na"&gt;count&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
          &lt;span class="p"&gt;};&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="na"&gt;afterDeserialize&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;counter&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;CounterInfoStateModel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AppModule&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Form Plugin
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Feature: Reset Form Action &lt;a href="//github.com/ngxs/store/pull/1604"&gt;(PR #1604)&lt;/a&gt;
&lt;/h4&gt;

&lt;p&gt;You can reset the form with the &lt;code&gt;ResetForm&lt;/code&gt; action.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This action resets the form and related form state.&lt;/li&gt;
&lt;li&gt;The form status, dirty, values, etc. will be reset by related form values after calling this action.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;form&lt;/span&gt; &lt;span class="na"&gt;[formGroup]=&lt;/span&gt;&lt;span class="s"&gt;"form"&lt;/span&gt; &lt;span class="na"&gt;ngxsForm=&lt;/span&gt;&lt;span class="s"&gt;"exampleState.form"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;formControlName=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"submit"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Add todo&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;(click)=&lt;/span&gt;&lt;span class="s"&gt;"resetForm()"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Reset Form&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;(click)=&lt;/span&gt;&lt;span class="s"&gt;"resetFormWithValue()"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Reset Form With Value&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;({...})&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;FormExampleComponent&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nx"&gt;form&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;FormGroup&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;FormControl&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;

  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nx"&gt;store&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Store&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;

  &lt;span class="nf"&gt;resetForm&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;store&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dispatch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ResetForm&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;exampleState.form&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}));&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;resetFormWithValue&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;store&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dispatch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ResetForm&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
        &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;exampleState.form&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="na"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Default Text&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="p"&gt;}),&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Improvement: Simplify &lt;code&gt;ngxsFormClearOnDestroy&lt;/code&gt; Attribute &lt;a href="//github.com/ngxs/store/pull/1662"&gt;(PR #1662)&lt;/a&gt;
&lt;/h4&gt;

&lt;p&gt;The &lt;code&gt;ngxsFormClearOnDestroy&lt;/code&gt; attribute previously required its declaration on the form element to be exactly &lt;code&gt;[ngxsFormClearOnDestroy]="true"&lt;/code&gt; to work.&lt;br&gt;
Since this is a simple boolean attribute, the mere presence of the attribute on the form element should imply the behavior. We have improved this attribute to recognize all valid forms of specification.&lt;/p&gt;

&lt;p&gt;For example, you can now just include the attribute like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;form&lt;/span&gt; &lt;span class="na"&gt;[formGroup]=&lt;/span&gt;&lt;span class="s"&gt;"form"&lt;/span&gt; &lt;span class="na"&gt;ngxsFormClearOnDestroy&lt;/span&gt; &lt;span class="na"&gt;ngxsForm=&lt;/span&gt;&lt;span class="s"&gt;"exampleState.form"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;formControlName=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;({...})&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;FormExampleComponent&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nx"&gt;form&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;FormGroup&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;FormControl&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;

  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nx"&gt;store&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Store&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This form will be cleared once the component is destroyed. Win!&lt;/p&gt;

&lt;h3&gt;
  
  
  HMR Plugin
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Deprecation
&lt;/h4&gt;

&lt;p&gt;As mentioned above, Angular 10 has &lt;a href="https://github.com/angular/angular/issues/35265#issuecomment-682123303" rel="noopener noreferrer"&gt;issues with HMR&lt;/a&gt;, and these issues prevented us from announcing official support from day 1. &lt;/p&gt;

&lt;p&gt;After many attempts to get it working again, we admitted defeat and had to make some hard decisions. After consulting with the community, we have decided to deprecate the HMR plugin until there is official Angular support for the HMR paradigm again. This goes against some of our fundamental philosophies that make the NGXS ecosystem such a reliable choice for your application, but in this case, we are forced by things that are outside of our control. &lt;/p&gt;

&lt;p&gt;Here is our poll to the community on our slack channel:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fp7ds0vgymap18w83prj4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fp7ds0vgymap18w83prj4.png" alt="Slack HMR Plugin poll"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The results were the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;💥 73% voted in favor of dropping the HMR plugin&lt;/li&gt;
&lt;li&gt;🙏 2% voted to keep the plugin&lt;/li&gt;
&lt;li&gt;🤷‍♀️ 25% didn't mind either way&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Upon discussion with the 2%, they were not aware that the storage plugin could be used to gain an almost identical experience and then supported the deprecation too. We have included details about this workaround in our docs.&lt;/p&gt;




&lt;h2&gt;
  
  
  Some Useful Links
&lt;/h2&gt;

&lt;p&gt;If you would like any further information on changes in this release please feel free to have a look at our changelog. The code for NGXS is all available at &lt;a href="https://github.com/ngxs/store" rel="noopener noreferrer"&gt;https://github.com/ngxs/store&lt;/a&gt; and our docs are available at &lt;a href="http://ngxs.io/" rel="noopener noreferrer"&gt;http://ngxs.io/&lt;/a&gt;. We have a thriving community on our slack channel so come and join us to keep abreast of the latest developments. Here is the slack &lt;a href="https://join.slack.com/t/ngxs/shared_invite/zt-by26i24h-2CC5~vqwNCiZa~RRibh60Q" rel="noopener noreferrer"&gt;invitation link&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>ngxs</category>
      <category>angular</category>
      <category>javascript</category>
      <category>statemanagement</category>
    </item>
    <item>
      <title>11 Reasons why you should use NGXS as State Management in your Angular apps</title>
      <dc:creator>Lex Kuncevic</dc:creator>
      <pubDate>Sat, 01 Aug 2020 12:32:09 +0000</pubDate>
      <link>https://dev.to/ngxs/11-reasons-why-you-should-use-ngxs-as-state-management-in-your-angular-apps-l82</link>
      <guid>https://dev.to/ngxs/11-reasons-why-you-should-use-ngxs-as-state-management-in-your-angular-apps-l82</guid>
      <description>&lt;p&gt;Developers tend to use state management solutions to solve some common problems developing modern single page applications. Building a modern web application using Angular you might &lt;strong&gt;not need&lt;/strong&gt; to opt-in for a state management solution right away (it depends) but when the day comes &lt;a href="https://www.ngxs.io" rel="noopener noreferrer"&gt;NGXS&lt;/a&gt; is your best choice and here is why.&lt;/p&gt;

&lt;p&gt;Why &lt;strong&gt;you&lt;/strong&gt; &lt;em&gt;should&lt;/em&gt; &lt;code&gt;choose&lt;/code&gt; &lt;strong&gt;NGXS&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Bulletproofed&lt;/strong&gt;: NGXS was built back in Feb 2018. Since then, for many years, it has been chosen by many  dev teams and companies as a state management solution for their Angular apps. Now there are 3.4+ million  npm downloads to date!&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Backed by an awesome team&lt;/strong&gt;: NGXS is an open source project maintained by a team of great software engineers from across the globe with a combined experience of 80+ years in software development.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Angular way&lt;/strong&gt;: NGXS written by Angular devs and for Angular devs. As a result, your store-related code uses a more familiar Angular approach that leverages dependency injection, decorators, etc. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Great Features&lt;/strong&gt;: There are many awesome features that NGXS offers: component communication, state operators, selectors and much more.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Plugins&lt;/strong&gt;: NGXS has a &lt;a href="https://www.ngxs.io/plugins" rel="noopener noreferrer"&gt;plugin&lt;/a&gt; system built-in - it is similar to Redux's meta reducers. You can use existing &lt;a href="https://www.ngxs.io/plugins" rel="noopener noreferrer"&gt;plugins&lt;/a&gt; to extend the functionality on top of your store or you can build your own plugin. Plugins that NGXS offering you: &lt;a href="https://www.npmjs.com/package/@ngxs/logger-plugin" rel="noopener noreferrer"&gt;Logger&lt;/a&gt;, &lt;a href="https://www.npmjs.com/package/@ngxs/devtools-plugin" rel="noopener noreferrer"&gt;Devtools&lt;/a&gt;, &lt;a href="https://www.npmjs.com/package/@ngxs/storage-plugin" rel="noopener noreferrer"&gt;Storage&lt;/a&gt;, &lt;a href="https://www.npmjs.com/package/@ngxs/form-plugin" rel="noopener noreferrer"&gt;Forms&lt;/a&gt;, &lt;a href="https://www.npmjs.com/package/@ngxs/websocket-plugin" rel="noopener noreferrer"&gt;Web Socket&lt;/a&gt;, &lt;a href="https://www.npmjs.com/package/@ngxs/router-plugin" rel="noopener noreferrer"&gt;Router&lt;/a&gt; and more!&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Less Boilerplate&lt;/strong&gt;: NGXS was originally invented in response to the complexity and amount of boilerplate present in other state management solutions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Backwards Compatibility&lt;/strong&gt;: NGXS team very strongly stands for backwards compatibility so by migrating to a new version of NGXS you can be assured that your codebase won’t require significant changes as part of the upgrade.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Consistency and Maintainability&lt;/strong&gt;: In practice it is much easier to maintain applications that build with the same fashion. When you use NGXS it gives your code a place to live and common patterns will emerge that will make for a much more maintainable codebase.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Documentation:&lt;/strong&gt; NGXS has a great documentation at &lt;a href="https://www.ngxs.io" rel="noopener noreferrer"&gt;NGXS.io&lt;/a&gt; in addition to that you can find some blog posts about NGXS on &lt;a href="https://medium.com/ngxs" rel="noopener noreferrer"&gt;medium blog&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Community&lt;/strong&gt;: The NGXS community is strong, you can join &lt;a href="https://tinyurl.com/ngxs-slack" rel="noopener noreferrer"&gt;NGXS slack channel&lt;/a&gt; if you have any questions or if you want to discuss anything or just to say hello. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;NGXS labs&lt;/strong&gt;: &lt;a href="https://www.ngxs.io/ngxs-labs/intro" rel="noopener noreferrer"&gt;NGXS labs&lt;/a&gt; is an &lt;a href="https://github.com/ngxs-labs" rel="noopener noreferrer"&gt;organization&lt;/a&gt; on github - the place to test out the new ideas and to play around and experiment with new cool features and new plugins that are not yet under the main &lt;a href="https://github.com/ngxs" rel="noopener noreferrer"&gt;NGXS organisation&lt;/a&gt;. Here is the list of the additional features and plugins currently available at NGXS labs:
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;      - &lt;a href="https://npmjs.com/package/@ngxs-labs/data" rel="noopener noreferrer"&gt;Data&lt;/a&gt; - NGXS Persistence API&lt;br&gt;
      - &lt;a href="https://npmjs.com/package/@ngxs-labs/emitter" rel="noopener noreferrer"&gt;Emitter&lt;/a&gt; - provides the opportunity to feel free from actions&lt;br&gt;
      - &lt;a href="https://npmjs.com/package/@ngxs-labs/immer-adapter" rel="noopener noreferrer"&gt;Immer adapter&lt;/a&gt; - declarative state mutations&lt;br&gt;
      - &lt;a href="https://npmjs.com/package/@ngxs-labs/dispatch-decorator" rel="noopener noreferrer"&gt;Dispatch decorator&lt;/a&gt; - provide separation of concern between the state management and the view&lt;br&gt;
      - &lt;a href="https://npmjs.com/package/@ngxs-labs/select-snapshot" rel="noopener noreferrer"&gt;Select snapshot&lt;/a&gt; - decorator that allows to get a snapshot of the state&lt;br&gt;
      - &lt;a href="https://npmjs.com/package/@ngxs-labs/async-storage-plugin" rel="noopener noreferrer"&gt;Async storage plugin&lt;/a&gt; - async Storage Plugin&lt;br&gt;
      - &lt;a href="https://npmjs.com/package/@ngxs-labs/entity-state" rel="noopener noreferrer"&gt;Entity state&lt;/a&gt; - entity adapter&lt;br&gt;
      - &lt;a href="https://npmjs.com/package/@ngxs-labs/actions-executing" rel="noopener noreferrer"&gt;Actions executing&lt;/a&gt; - notifies if action is being executed&lt;br&gt;
      - &lt;a href="https://npmjs.com/package/@ngxs-labs/attach-action" rel="noopener noreferrer"&gt;Attach action&lt;/a&gt; - attaching independent, pure and easy to test Action Handlers to NGXS State&lt;br&gt;
      - &lt;a href="https://npmjs.com/package/@ngxs-labs/firestore-plugin" rel="noopener noreferrer"&gt;Firestore plugin&lt;/a&gt; - firestore plugin for NGXS&lt;/p&gt;

&lt;p&gt;So as you can see there are lots of reasons why you may want to consider NGXS as a state management solution for your Angular applications. To get started check up the documentation at &lt;a href="//ngxs.io"&gt;ngxs.io&lt;/a&gt; and if you have any questions you can join the &lt;a href="https://tinyurl.com/ngxs-invite" rel="noopener noreferrer"&gt;slack channel&lt;/a&gt; to discuss or just comment below.&lt;/p&gt;




&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;My name is Aliaksei Kuncevič. I am teaching Angular and Web Technology. Helping dev teams to adopt Angular in the most efficient way. GDE, member of the NGXS Core Team.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I hope you find this content helpful and if so, please help to spread this article so more people can benefit from it.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;If you want to learn more Angular tips and tricks join my newsletter at &lt;a href="https://kuncevic.dev?ref=dev" rel="noopener noreferrer"&gt;kuncevic.dev&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;If you want to know more about Angular subscribe for &lt;a href="https://angularrocks.com/subscribe" rel="noopener noreferrer"&gt;Angular Rocks&lt;/a&gt; podcast&lt;/em&gt; 🎙&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>angular</category>
      <category>ngxs</category>
      <category>redux</category>
    </item>
  </channel>
</rss>
