<?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 Tanya Gray on Medium]]></title>
        <description><![CDATA[Stories by Tanya Gray on Medium]]></description>
        <link>https://medium.com/@tanya?source=rss-72d031eb1d0c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*zrECgZMepvij0A6btuxPnw.png</url>
            <title>Stories by Tanya Gray on Medium</title>
            <link>https://medium.com/@tanya?source=rss-72d031eb1d0c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 02:20:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tanya/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[NgRx TLDR]]></title>
            <link>https://medium.com/@tanya/ngrx-tldr-616423403a20?source=rss-72d031eb1d0c------2</link>
            <guid isPermaLink="false">https://medium.com/p/616423403a20</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[ngrx]]></category>
            <dc:creator><![CDATA[Tanya Gray]]></dc:creator>
            <pubDate>Tue, 11 Apr 2023 04:04:28 GMT</pubDate>
            <atom:updated>2023-04-11T04:04:28.823Z</atom:updated>
            <content:encoded><![CDATA[<p>Sick of too many big words? This is NgRx, simplified.</p><h4>TL;DR:</h4><ul><li><strong>Actions</strong> are basically events. They go “pew pew” with a unique name, and some data attached, just like an event.</li><li><strong>Reducers</strong> are like event handlers that react to <strong>Actions</strong>. Their only job is to update the app state and nothing else. App state is just a simple object, like a big blob of JSON, so a reducer takes in <strong>Actions</strong> (events) and merges the event data into the giant blob of JSON.</li><li><strong>Effects</strong> are also like event handlers that react to <strong>Actions</strong>, but they’re allowed to do some logic. An <strong>Effect</strong> always takes an Action in, spits an Action out. In the middle they usually make an API call or run some other data processing function, and so they’ll be spitting out either a “success” Action or a “failure” Action<strong>.</strong></li><li><strong>Selectors</strong> are for getting data out of the app state. Once you create a selector, it’ll watch the app state and then emit the new value each time the underlying data changes.</li></ul><p>👌 nice.</p><p>Further Reading:</p><ul><li><a href="https://medium.com/@tanya/ngrx-core-concepts-2023-aacb786e5944">NgRx Core Concepts 2023</a></li><li><a href="https://medium.com/@tanya/understanding-ngrx-effects-and-the-action-stream-1a74996a0c1c">Understanding NgRx Effects and the Action Stream</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=616423403a20" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NgRx Core Concepts for Beginners in 2023]]></title>
            <link>https://medium.com/@tanya/ngrx-core-concepts-2023-aacb786e5944?source=rss-72d031eb1d0c------2</link>
            <guid isPermaLink="false">https://medium.com/p/aacb786e5944</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[ngrx-effects]]></category>
            <category><![CDATA[ngrx]]></category>
            <dc:creator><![CDATA[Tanya Gray]]></dc:creator>
            <pubDate>Tue, 11 Apr 2023 04:03:32 GMT</pubDate>
            <atom:updated>2023-04-11T04:37:34.561Z</atom:updated>
            <content:encoded><![CDATA[<p>NgRx is a library for Angular which manages a global data store for your app. This article covers some of the core concepts of NgRx:</p><ul><li><strong>Actions </strong>are like events</li><li><strong>Reducers</strong> write data to the state</li><li><strong>Effects</strong> do API calls and map actions to other actions</li><li><strong>Selectors</strong> are for reading data from the state</li></ul><p>An Angular app using NgRx will usually have a store directory which should be organised into “sub-stores” for each major data type in the app.</p><p>Sub-stores are referred to as store <strong>Features. </strong>Each Feature, like “Users” or “Projects” will have its own directory, and its own <strong>Reducer, Actions, Effects </strong>and<strong> Selectors.</strong></p><p>This is a concept guide, not a getting started guide (sorry!). Only small snippets of code are included as examples.</p><h4><strong>Actions are like events</strong></h4><p>Actions have unique names, and they are dispatched with some data attached — just like an event.</p><p>Actions are defined in groups like this:</p><pre>const ProjectActions = createActionGroup({<br>  source: &#39;Project API&#39;,<br>  events: {<br>    // defining events with payload using the `props` function<br>    &#39;Load Project&#39;: props&lt;{ projectId: number }&gt;(),<br>    &#39;Load Project Success&#39;: props&lt;{ project: Project }&gt;(),<br>    &#39;Load Project Failure&#39;: props&lt;{ error: Error }&gt;(),<br>  },<br>});</pre><p>NgRx works some magic so that when you use each Action in your code, you refer to it by the <strong>type</strong> you gave it (the string name / key), but as a camel-cased property of the Action Group.</p><p>So from the example above, the Action &#39;Load Project&#39; would be referred to as ProjectActions.loadProject().</p><p>An Action is <strong>created</strong> and <strong>dispatched</strong> like this:</p><pre>const loadProject = ProjectActions.loadProject({ projectId: 123 });<br>store.dispatch(loadProject);</pre><p>Actions are just simple objects, so a loadProject action is really just something like this inside:</p><pre>{<br>  type: &#39;[Project API] Load Project&#39;,<br>  projectId: 123<br>}</pre><p>The type has to be unique across all actions in your app, so it’s common to add a namespaced <strong>source </strong>like [Project API] to make debugging easier via Redux Dev Tools and to avoid naming conflicts. NgRx does this automatically when you use the createActionGroup function to define your Actions.</p><p>In NgRx, both <strong>Reducers</strong> and <strong>Effects</strong> can listen for specific <strong>Actions</strong>.</p><p>This means an <strong>Action</strong> can trigger a <strong>Reducer</strong> (to change the app state) or trigger an <strong>Effect</strong> (to go load some data) or it could do both.</p><p>Read the <a href="https://ngrx.io/guide/store/actions">official docs for Actions</a>.</p><h4>Reducers update the state</h4><p>A <strong>Reducer</strong> is a collection of functions that each update a small part of the global app state.</p><p>Each Reducer function takes in an <strong>Action</strong> and the <strong>current app state, </strong>merges the Action’s data into the app state, and returns the new <strong>updated app state.</strong></p><p>Reducers <strong>write</strong> data to the global app state, and Selectors <strong>read</strong> data from the global app state.</p><p>A <strong>Reducer</strong> is usually created like this:</p><pre>export const projectsReducer = createReducer(<br>  initialState,<br><br>  on(ProjectActions.loadProject, (state) =&gt; ({<br>    ...state,<br>    loading: true<br>  })),<br><br>  on(ProjectActions.loadProjectSuccess, (state, action) =&gt; ({<br>    ...state,<br>    loading: false,<br>    projects: action.projects<br>  })),<br><br>  on(ProjectActions.loadProjectFailure, (state, action) =&gt; ({<br>    ...state,<br>    loading: false,<br>    errors: [<br>      ...state.errors,<br>      action.error<br>    ]<br>  })),<br>)</pre><p>The <strong>initialState </strong>is defined by you, it’s whatever app state you want to start from when the app is first loaded. Each <strong>on() </strong>function updates the app state when a particular Action happens.</p><p>Not every Action needs a matching Reducer, it’s okay to have some Actions which don’t update the app state. A Reducer doesn’t have to process every Action, it can just ignore any Actions it doesn’t care about.</p><p>Reducers should ideally do little to no logic. They should rely on being provided clean Actions where the data is already in the correct format.</p><p>The state should be <strong>immutable</strong>, which is why you’ll see Reducers using the ... spread operator to return a <strong>copy</strong> of the state including the new data, rather than just updating some specific properties.</p><p>If an Action’s data needs cleaning, the logic for cleaning should be in a <strong>Service</strong> and the Action should be processed by an <strong>Effect.</strong></p><p>Read the <a href="https://ngrx.io/guide/store/reducers">official docs for Reducers</a>.</p><h4><strong>Effects map actions to other actions</strong></h4><p>An<strong> Effect</strong> usually watches for an <strong>Action</strong> in your app, executes a function (usually in a Service), and then dispatches another follow-up Action.</p><p>An Effect is written as an Observable.</p><p>Most Effects look something like this:</p><pre>loadProject$ = createEffect(() =&gt;<br>  this.actions$.pipe(<br>    ofType(ProjectActions.loadProject),<br>    exhaustMap((action) =&gt; <br>      this.projectService.getOne(action.projectId).pipe(<br>        map((project) =&gt; ProjectActions.loadProjectSuccess({ project }),<br>        catchError((error) =&gt; of(ProjectActions.loadProjectFailure({ error })))<br>      )<br>    )<br>  )<br>);</pre><p>To translate the Effect above: When an action <strong>ofType </strong>loadProject<strong> </strong>happens, use exhaustMap to call projectService.getOne(projectId) and then map the result to a new Action — either loadProjectSuccess or loadProjectFailure.</p><p>The Action going in is a loadProject.</p><p>The Action coming out will be one of loadProjectSuccess or loadProjectFailure.</p><p>Sometimes, an Effect may not do an API call, but instead just process an action into one or more other actions, to trigger one or more other Effects.</p><p>Very rarely, an Effect may call a function where the result is not important, and so it doesn’t dispatch any kind of success or failure event:</p><pre>export const loadProjectFailure = createEffect(() =&gt;<br>  this.actions$.pipe(<br>    ofType(ProjectActions.loadProjectFailure),<br>    tap(({ error }) =&gt; console.error(&#39;Project load failed:&#39;, error))<br>  ),<br>  { dispatch: false }<br>);</pre><p>The example above shows adding { dispatch: false } to make this Effect a “dead end” which will not emit an Action.</p><p>Read the <a href="https://ngrx.io/guide/effects">official docs for Effects</a>.</p><h4>Selectors are for getting data</h4><p>A <strong>Selector</strong> pulls data out of the global app state. It reads from the big JSON data blob that is maintained by the apps’ <strong>Reducers</strong>.</p><p>Usually, each store <strong>Feature</strong> defines a selector for the entire Feature state — all the data related to that Feature, like this:</p><pre>const projectsFeature = createFeatureSelector&lt;ProjectsState&gt;(&#39;projects&#39;);</pre><p>That’s because Selectors are <strong>composable,</strong> so you can make a selector based on another selector. Once you have a selector for a whole Feature, you can drill in deeper to select more specific data.</p><p>This is how you select a specific piece of data from a Feature:</p><pre>export const getAllProjects = createSelector(<br>  projectsFeature,<br>  (state: ProjectsState) =&gt; state.projects<br>);</pre><p>Selectors are Observables, so they emit new values over time as the underlying app state changes.</p><p>Selectors can be used from anywhere, but they are most commonly seen in <strong>Component </strong>code, providing data to show in the template.</p><p>A Selector is used in a component’s class like this:</p><pre>public allProjects$ = this.store.select(getAllProjects);</pre><p>A Selector’s value can be displayed as JSON-formatted text in a template like this:</p><pre>&lt;pre&gt;{{ allProjects$ | async | json }}&lt;/pre&gt;</pre><p>Or the value can be passed as an input like this:</p><pre>&lt;app-projects-list [projects]=&quot;$allProjects | async&quot;&gt;&lt;/app-projects-list&gt;</pre><p>Read the <a href="https://ngrx.io/guide/store/selectors">official docs for Selectors</a>.</p><p>There’s a bunch of different “personal preference” styles for writing NgRx apps, but the core concepts remain the same.</p><p>Data is handled in a continuous way, where values change dynamically over time based on changes to the app state behind the scenes.</p><ul><li><strong>Actions </strong>are like events, they carry data. They can be used to trigger an Effect, or deliver data to a Reducer.</li><li><strong>Reducers</strong> write data to the state. They run when an Action happens that they’re configured to capture.</li><li><strong>Effects</strong> handle async functionality to map one Action into another. They emit Actions that may contain data for the Reducer to add to the state, or may trigger other Effects.</li><li><strong>Selectors</strong> are for reading data from the state, and their values change dynamically as the underlying app state evolves.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aacb786e5944" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sentry Source Maps for Angular with GitHub Actions]]></title>
            <link>https://medium.com/@tanya/sentry-source-maps-for-angular-with-github-actions-ff9a2c617f79?source=rss-72d031eb1d0c------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff9a2c617f79</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[sentry]]></category>
            <dc:creator><![CDATA[Tanya Gray]]></dc:creator>
            <pubDate>Sun, 09 Apr 2023 04:43:56 GMT</pubDate>
            <atom:updated>2023-04-09T04:43:56.699Z</atom:updated>
            <content:encoded><![CDATA[<p>If configured correctly, Sentry can provide a really useful developer experience where each Sentry error event shows:</p><ul><li>The <strong>version </strong>or versions where the error is occurring.</li><li>The <strong>line of code</strong> that caused the error.</li><li>The <strong>suspect commit</strong> most likely to have introduced the issue (and who contributed that code).</li></ul><p>Pair these features with auto-posting to Slack when new errors occur, and you suddenly have a really quick and convenient way to identify, discuss and address issues as they happen.</p><p>You also get some really neat stats about your app’s quality over time, as you’ll be able to view error rates and crash rates on a version-by-version basis.</p><p>I’ve included a full discussion below, but if you want to “just make it work” you can jump to the code for both Angular and GitHub Actions under <a href="#a-workflow-that-works"><strong>A Workflow that Works</strong></a> below.</p><h3>Sections</h3><ul><li><a href="#how-sentry-source-maps-work"><strong>How Sentry source maps work</strong></a></li><li><a href="#terminology"><strong>Terminology</strong></a><br>- Project<br>- Version<br>- Distribution</li><li><a href="#angular-challenges"><strong>Angular challenges</strong></a></li><li><a href="#a-workflow-that-works"><strong>A workflow that works</strong></a><br>- Angular AppInitializer for Sentry<br>- Build and Deploy workflow for GitHub Actions</li></ul><h3>How Sentry source maps work</h3><p>In Sentry, <strong>source maps</strong> are matched up with your app’s <strong>error events</strong> by looking at the <strong>project</strong>, <strong>version</strong>, and <strong>distribution</strong> ID for the app where the error occurred.</p><p>In other words:</p><ul><li>Source maps must be published to Sentry with a <strong>project</strong>, <strong>version</strong>, and <strong>distribution</strong>.</li><li>Your Angular application must specify the same <strong>project</strong>, <strong>version</strong>, and <strong>distribution</strong> when it initialises Sentry at runtime.</li></ul><h3>Terminology</h3><h4>Project</h4><p>The <strong>project</strong> should be familiar from the Sentry web UI. This is the name of your app, and should usually match up with the name of your repo, or used in your package.json — for example customer-portal-ui.</p><h4>Version</h4><p>Your app’s <strong>version</strong> should be unique across <em>all</em> of your Sentry projects.</p><p>It is <em>not</em> enough to just use something like v1.1.0 with Sentry, because Sentry groups errors by version across <em>all</em> projects. That is, if you have more than one Sentry project with a v1.1.0, Sentry will consider all v1.1.0 errors from all projects to be part of the same super-project. This will make filtering errors by version more difficult in the Sentry UI.</p><p>For Sentry purposes, your <strong>version</strong> should be scoped to your app, eg. customer-portal-ui@v1.1.0 is a recommended format for JavaScript apps.</p><h4>Distribution</h4><p>Your app’s <strong>distribution</strong> is used to differentiate builds of the same version.</p><p>In Angular it is common to build for each environment separately. Building per-environment means that your dist files are slightly different each time you build, which means your sourcemap files will be different too.</p><p>Sentry needs the <strong>distribution</strong> identifier so it can know the difference between your app.js you built for dev and your app.js that you built for prod, because even if both were v1.1.0 the compiled dist files will still be slightly different.</p><p>For an Angular app, you could set your <strong>distribution</strong> to the environment you built for, eg. dev or prod. For traceability, I’ve opted to use the commit hash <em>plus</em> the environment, eg. abcdef123456-dev.</p><h3>Angular Challenges</h3><p>Sentry source maps are challenging for Angular apps for two reasons:</p><ol><li>Your Angular app needs to know the <strong>project, version </strong>and <strong>distribution</strong> at <strong>runtime</strong>… but you may not know the version or distribution until you run the build command. We can solve this by loading the <strong>Sentry Config </strong>from a JSON file that we can update separately from the app build.</li><li>Your Angular app may use <strong>output hashing</strong>, where the file name includes a generated suffix, eg. main.a1b2c3d4.js. This is a good security practice, but is incompatible with the way Sentry uploads source maps because Sentry modifies the JS files in dist with identifiers for it to use at runtime. We can solve this by disabling output hashing.</li></ol><h3><strong>A workflow that works</strong></h3><p>We need to modify our Angular app to <strong>load the Sentry config dynamically</strong> and then modify our GitHub workflow to <strong>write the Sentry config</strong> with the correct settings — <em>after</em><strong><em> </em></strong><em>we build</em> the app but <em>before we deploy</em> the app.</p><h4>Angular App Initializer for Sentry</h4><p>Instead of compiling the Sentry config into the build, we can load it from a JSON file at runtime. This will allow us to provide the correct Sentry configuration settings, <em>separate</em><strong><em> </em></strong>from rebuilding the app itself.</p><p>Create a placeholder config file so that it’s easy for developers to understand where the Sentry settings are being loaded from:</p><p>Create file: src/assets/config/sentry.json</p><pre>{<br>  &quot;environment&quot;: &quot;local&quot;,<br>  &quot;release&quot;: &quot;local&quot;,<br>  &quot;dist&quot;: &quot;local&quot;<br>}</pre><p>And then update your Sentry module to load that JSON file:</p><pre>// file: app/shared/sentry/sentry.module.ts<br><br>import { NgModule, ErrorHandler, APP_INITIALIZER } from &#39;@angular/core&#39;;<br>import { SentryErrorHandler } from &#39;./sentry-error-handler.service&#39;;<br>import { SentryDataCapture } from &#39;./sentry-data-capture.service&#39;;<br>import { environment } from &#39;src/environments/environment&#39;;<br>import * as Sentry from &#39;@sentry/browser&#39;;<br>import { HttpClient } from &#39;@angular/common/http&#39;;<br><br>/**<br> * Factory function initializes Sentry configuration<br> * BEFORE the app is initialized.<br> */<br>const initSentry = async (http: HttpClient) =&gt; {<br>  const sentryConfig = await http<br>    .get(&#39;assets/config/sentry.json&#39;)<br>    .toPromise()<br>    .catch(() =&gt; null);<br><br>  if (!sentryConfig) {<br>    // eslint-disable-next-line no-console<br>    console.error(&#39;Sentry initialization failed, sentry.json not found&#39;);<br>    return;<br>  }<br><br>  if (!environment.sentry.enabled) {<br>    // eslint-disable-next-line no-console<br>    console.error(&#39;Sentry config loaded, but Sentry is not enabled for this build.&#39;);<br>    return;<br>  }<br><br>  Sentry.init({<br>    dsn: &#39;[YOUR_SENTRY_DSN_HERE]&#39;,<br>    ...sentryConfig,<br>  });<br>};<br><br>@NgModule({<br>  providers: [<br>    SentryDataCapture,<br>    { provide: ErrorHandler, useClass: SentryErrorHandler },<br>    {<br>      provide: APP_INITIALIZER,<br>      useFactory: (httpClient: HttpClient) =&gt; () =&gt; initSentry(httpClient),<br>      deps: [HttpClient],<br>      multi: true,<br>    },<br>  ],<br>})<br>export class SentryModule {}</pre><h4>Build and Deploy workflow for GitHub Actions</h4><p>This can theoretically all be done inline in one file, but for clarity I recommend you do as I have done and split the Sentry CLI steps into a reusable workflow, then consume that in your main build and deploy workflow.</p><p>First, make the reusable workflow that handles the Sentry releases. This workflow uses the raw Sentry CLI, so each step can be easily modified for your own use case.</p><p>Create a new file .github/actions/sentry-release/action.yml</p><pre>###<br># This composite action uses the Sentry CLI to:<br># - Create a Sentry Release<br># - Upload Source Maps<br># - Finalize the release<br># - Create a Sentry Deploy of this release to the given environment<br>#<br># The action also optionally uses the `write_config_file` input to<br># write the Sentry Release data to a JSON file. This JSON file can<br># be used in the application code to correctly match up the app<br># with the correct Sentry Release at runtime.<br>#<br># Example generated JSON:<br>#<br># {<br>#   &quot;environment&quot;: &quot;dev&quot;,<br>#   &quot;release&quot;: &quot;customer-portal-ui@v1.0.0&quot;,<br>#   &quot;dist&quot;: &quot;v1.0.0&quot;<br># }<br>#<br># Required env vars:<br># - SENTRY_ORG<br># - SENTRY_PROJECT<br># - SENTRY_AUTH_TOKEN<br>#<br># Example usage:<br>#  - name: Create Sentry Release<br>#    uses: ./.github/actions/sentry-release<br>#    env:<br>#      SENTRY_ORG: my-org-name<br>#      SENTRY_PROJECT: customer-portal-ui<br>#      SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_TOKEN_RELEASES }}<br>#    with:<br>#      release_id: ${{ env.SENTRY_RELEASE_ID }}<br>#      distribution_id: ${{ env.SENTRY_DISTRIBUTION_ID }}<br>#      environment_name: dev<br>#      environment_url: https://your-environment-url.com<br>#      sourcemaps_dir: ./dist/customer-portal-ui<br>#      write_config_file: ./dist/customer-portal-ui/assets/config/sentry.json<br>#<br>###<br><br>name: &#39;Sentry Release&#39;<br>description: &#39;Creates a Sentry Release, uploads Source Maps and registers a Sentry Deployment based on the current commit.&#39;<br><br>inputs:<br>  release_id:<br>    description: &#39;Unique ID for the release, usually [projectName]@[version]&#39;<br>    required: true<br><br>  distribution_id:<br>    description: &#39;Unique ID for the build, to differentiate sourcemap sets for different builds of the same version. This ID must match the dist provided in the source code when configuring Sentry.&#39;<br>    required: true<br><br>  environment_name:<br>    description: &#39;The name of the deployment environment, eg. dev/stage/prod&#39;<br>    required: true<br><br>  environment_url:<br>    description: &#39;The URL where this deployment can be viewed&#39;<br>    required: false<br>    default: &#39;&#39;<br><br>  sourcemaps_dir:<br>    description: &#39;Path to the folder containing all source maps and compiled code&#39;<br><br>  write_config_file:<br>    description: &#39;Optional JSON file where Sentry configuration should be written&#39;<br>    required: false<br><br>runs:<br>  using: &#39;composite&#39;<br><br>  steps:<br>    - name: Install Sentry CLI<br>      shell: bash<br>      run: npm install @sentry/cli -g<br><br>    # A release is a specific version of the code.<br>    #<br>    # A release is usually represented by a tagged<br>    # commit, like v1.0.0.<br>    #<br>    # Releases can be registered with Sentry at any time<br>    # before the release is deployed to a specific environment.<br>    #<br>    # A release is global per org (not per project),<br>    # so releases should be named using a format like<br>    # customer-portal-ui@v1.0.0 for uniqueness<br>    #<br>    # https://docs.sentry.io/product/cli/releases/<br>    #<br>    - name: Create Release<br>      shell: bash<br>      run: |<br>        sentry-cli releases \<br>        new ${{ inputs.release_id }}<br><br>    # Associate commits with the release so that Sentry<br>    # can use the information to identify which commits<br>    # may have caused a particular error to start occurring.<br>    #<br>    - name: Associate Commits<br>      shell: bash<br>      run: |<br>        sentry-cli releases \<br>        set-commits ${{ inputs.release_id }} \<br>        --auto<br><br>    # Source maps are associated with a release (a build)<br>    # of a specific version of the app. These source maps<br>    # can then be used for that version of the app in any<br>    # environment it is deployed to.<br>    #<br>    # Options:<br>    # https://github.com/getsentry/sentry-cli/blob/master/js/releases/options/uploadSourcemaps.js<br>    #<br>    # All Options:<br>    #   --ignore<br>    #   --ignore-file<br>    #   --decompress<br>    #   --rewrite<br>    #   --no-sourcemap-reference<br>    #   --strip-prefix<br>    #   --strip-common-prefix<br>    #   --url-prefix<br>    #   --url-suffix<br>    #   --ext<br>    #<br>    - name: Upload Source Maps<br>      shell: bash<br>      run: |<br>        sentry-cli releases \<br>        files ${{ inputs.release_id }} \<br>        upload-sourcemaps ${{ inputs.sourcemaps_dir }} \<br>        --dist ${{ inputs.distribution_id }} \<br>        --validate<br><br>    # Mark this release as complete. This should be called<br>    # after all artifacts have been uploaded.<br>    #<br>    - name: Finalize Release<br>      shell: bash<br>      run: |<br>        sentry-cli releases \<br>        finalize ${{ inputs.release_id }}<br><br>    # A &quot;deploy&quot; represents a &quot;release&quot; (a specific version/build)<br>    # being deployed to a specific environment.<br>    #<br>    # One release version may be present on more than one<br>    # environment, eg. the latest version may be present on<br>    # both the staging and prod environments simultaneously.<br>    #<br>    # https://github.com/getsentry/sentry-cli/blob/master/js/releases/options/deploys.js<br>    #<br>    # Available Options:<br>    #   --env         : name of the environment the release has been deployed to<br>    #   --url         : URL that points to the deployment<br>    #   --started     : unix timestamp when the deployment started<br>    #   --finished    : unix timestamp when the deployment finished<br>    #   --time        : deployment duration in seconds. This can be specified alternatively to `started` and `finished`<br>    #   --name        : human readable name for this deployment<br>    #<br>    - name: Create Deployment<br>      shell: bash<br>      run: |<br>        sentry-cli releases \<br>        deploys ${{ inputs.release_id }} \<br>        new \<br>        --env ${{ inputs.environment_name }} \<br>        --url ${{ inputs.environment_url }}<br><br>    # The output JSON file is optional, but recommended.<br>    # It specifies the environment, release, and dist<br>    # that were registered with Sentry via this action.<br>    # These values must be passed to Sentry.init() at<br>    # runtime in order for errors from the running app<br>    # to correctly match up with the relevant Release<br>    # in Sentry, and to display the correct source maps.<br>    #<br>    - name: Output Config JSON<br>      if: ${{ inputs.write_config_file }}<br>      uses: RadovanPelka/github-action-json@v1.0.1<br>      with:<br>        path: ${{ inputs.write_config_file }}<br>        replaceWith: |<br>          {<br>            &quot;environment&quot;: &quot;${{ inputs.environment_name }}&quot;,<br>            &quot;release&quot;: &quot;${{ inputs.release_id }}&quot;,<br>            &quot;dist&quot;: &quot;${{ inputs.distribution_id }}&quot;<br>          }</pre><p>Second, consume that action in your build and deploy GitHub workflow. Note that this workflow is specific to my own use case, and yours may be quite different.</p><p>The important new step is <strong>Create Sentry Release</strong> which uses the <strong>sentry-release</strong> action defined previously, and is positioned <strong>after the build </strong>but <strong>before the deploy.</strong></p><p>The workflow makes use of some secrets and env vars you may also have configured differently in your own repo.</p><p>File .github/workflows/build-and-deploy.yml :</p><pre>#<br># Provide an environment name and a tag name to build<br># and publish the tagged commit to the given environment.<br>#<br># Environment variables are managed in GitHub settings.<br>#<br><br>name: Build + Deploy [manual]<br><br>on:<br>  workflow_dispatch:<br>    inputs:<br>      environment:<br>        description: Target environment for deployment<br>        type: environment<br>      tag_name:<br>        description: Release tag name to publish (eg. v1.0.0)<br>        type: string<br><br>permissions:<br>  id-token: write<br>  contents: read<br><br>jobs:<br>  build-and-deploy:<br>    runs-on: ubuntu-latest<br>    environment:<br>      name: ${{ inputs.environment }}<br>      url: ${{ vars.DEPLOYMENT_URL }}<br><br>    steps:<br>      - name: Checkout Code<br>        uses: actions/checkout@v3<br>        with:<br>          ref: ${{ inputs.tag_name }}<br><br>      - name: Install Dependencies<br>        uses: ./.github/actions/install-dependencies<br><br>      - name: Build<br>        run: npm run build:${{ inputs.environment }}<br><br>      - name: Create Sentry Release<br>        uses: ./.github/actions/sentry-release<br>        env:<br>          SENTRY_ORG: acme-inc<br>          SENTRY_PROJECT: customer-portal-ui<br>          SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_TOKEN_RELEASES }}<br>        with:<br>          release_id: customer-portal-ui@${{ inputs.tag_name }}<br>          distribution_id: ${{ github.sha }}-${{ inputs.environment }}<br>          environment_name: ${{ inputs.environment }}<br>          environment_url: ${{ vars.DEPLOYMENT_URL }}<br>          sourcemaps_dir: ./dist/customer-portal-ui<br>          write_config_file: ./dist/customer-portal-ui/assets/config/sentry.json<br><br>      - name: Deploy<br>        uses: ./.github/actions/aws-deploy<br>        with:<br>          s3-deploy-arn: ${{ vars.S3_DEPLOY_ARN }}<br>          s3-deploy-bucket: ${{ vars.S3_DEPLOY_BUCKET }}<br>          s3-deploy-directory: ${{ vars.S3_DEPLOY_DIRECTORY }}<br>          cloudfront-distribution-id: ${{ vars.CLOUDFRONT_DISTRIBUTION_ID }}<br><br>      - name: Report<br>        if: ${{ success() }}<br>        run: echo &quot;Deployed ${{ inputs.tag_name }} to ${{ inputs.environment }} (${{ vars.DEPLOYMENT_URL }})&quot;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff9a2c617f79" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Configuring Firebase Admin SDK with Express]]></title>
            <link>https://medium.com/@tanya/configuring-firebase-admin-sdk-with-express-931b02ee2f91?source=rss-72d031eb1d0c------2</link>
            <guid isPermaLink="false">https://medium.com/p/931b02ee2f91</guid>
            <category><![CDATA[express]]></category>
            <category><![CDATA[firebase-admin-sdk]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[firebase]]></category>
            <dc:creator><![CDATA[Tanya Gray]]></dc:creator>
            <pubDate>Tue, 14 Sep 2021 11:16:51 GMT</pubDate>
            <atom:updated>2021-09-14T11:23:34.278Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Using dotenv to set your </em><em>GOOGLE_APPLICATION_CREDENTIALS environment variable allows you to store your credentials JSON in a local folder in your project, and to more closely mimic the Google Cloud environment without changes to your code.</em></p><p><strong><em>Brief version for people in a rush, I know how it is:</em></strong></p><ol><li>Generate service account credentials JSON file in Firebase</li><li>Copy JSON into your Express project at /.firebase/service-account.json</li><li>Create .env file in project root</li><li>Add variable in the .env file GOOGLE_APPLICATION_CREDENTIALS=./firebase/service-account.json</li><li>Install dotenv npm i dotenv -D</li><li>Change your start script from node . to node -r dotenv/config .</li></ol><p>If that didn’t make sense to you, read on for more detailed instructions :)</p><p>More advanced readers may prefer this more in-depth explanation:</p><blockquote><a href="https://medium.com/google-cloud/firebase-separating-configuration-from-code-in-admin-sdk-d2bcd2e87de6"><strong><em>Firebase: Separating configuration from code in Admin SDK</em></strong></a><em><br>by Hiranya Jayathilaka on Medium [4 min read]</em></blockquote><h4>Detailed instructions:</h4><p>Google recommends that you use the applicationDefault() method to load the firebase-admincredentials path from an environment variable, rather than passing in the file path as a string.</p><pre>import * as admin from &quot;firebase-admin&quot;;</pre><pre>admin.initializeApp({<br>  credential: admin.credential.applicationDefault(), // &lt;= THIS!<br>  databaseURL: &quot;https://my-project-XXXXX.firebasedatabase.app&quot;<br>});</pre><pre>export const db = admin.database();</pre><p>The applicationDefault() method looks for an environment variable called GOOGLE_APPLICATION_CREDENTIALS which should contain your secret connection information.</p><p>This will work automatically on any Google Cloud environment because the variable is configured there by default, but for local development you would need to set that environment variable yourself, else it won’t be defined and this code won’t work. Adding the variable to your PATH is the approach recommended in the docs.</p><p>In the docs for <a href="https://firebase.google.com/docs/admin/setup">Firebase Admin SDK</a> they also recommend that the file path to your credentials file <em>must</em> be an absolute path, and that relative paths are not supported. That kinda sucks — I like to keep my configuration files alongside my code, so they’re easy to find.</p><p>By using the dotenv library instead, there is no need to update your PATH because the environment variable will be set automatically each time you start your Express app. This approach also just happens to support relative paths, hooray!</p><h4>Get service credentials JSON file from Firebase</h4><p>You’ll need to create a service account credentials file from Firebase, if you haven’t done this already. Create the JSON file using the big blue “Generate new private key” button, and download it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T8OubEFO9LyZb6E7umyCew.png" /><figcaption>Click the button “Generate new private key” to create a service account credentials JSON file.</figcaption></figure><h4>Save the JSON file in your project</h4><p>I prefer to keep my credentials inside my project directory for convenience, but you can keep it elsewhere in your filesystem if you prefer.</p><p>In this case I created a folder called .firebase in the root of my project and copied the credentials file there. I also renamed the file to service-account.json to make it a bit more manageable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JKvaIx2lKuhAT7fw5z4dOA.png" /><figcaption>Rename the credentials file to service-account.json and save it to a .firebase folder inside your project.</figcaption></figure><p>Note that you should <strong>always</strong> make <strong>absolutely sure</strong> that this file is added to your project’s .gitignore, and that the service account key is <strong>absolutely not</strong> committed to your Git repository.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DOjtrTx9nkaywnwmUaXfsQ.png" /><figcaption>Always use .gitignore to exclude any credentials files from being uploaded to your repository.</figcaption></figure><h4>Create a .env file</h4><p>This file should be in your project root and should be named .env so that the dotenv library can find it automatically.</p><p>This file will represent a list of environment variables that you want to load every time you run your app. You can use it for setting other environment variables too, not just the Firebase credentials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m9syOjUwlrXq8nWh1sFqYw.png" /><figcaption>The .env file can be used to set any environment variables your app needs, eg. the PORT for Express</figcaption></figure><p>Create the file and then add the following entry:</p><pre>GOOGLE_APPLICATION_CREDENTIALS = .firebase/service-account.json</pre><p>And save the file! Don’t forget! It’s okay, happens to all of us sometimes.</p><h4>Install the dotenv library</h4><p>This library can load environment variables from the .env file inside your project. The dotenv library is only needed in the local development environment, not in production, so we use the -D flag to save it to our project’s devDependencies.</p><pre>npm i dotenv -D</pre><p>Loading environment variables dynamically makes it really easy to ensure your project has everything configured correctly every time you run it.</p><h4>Run dotenv when you start your app</h4><p>Each time you run your app from now on, you should also run the dotenv library. You can do this from the command line or from your package.json — wherever you run your Node start command.</p><p>For example, if you usually run your app from the command line using something like:</p><pre>node .</pre><p>…then you will need to change to a command like this:</p><pre>node -r dotenv/config .</pre><p>The extra -r dotenv/config makes sure that the environment variables are all loaded before your Express app starts up. This is called a “preload” and you can read about it in the <a href="https://github.com/motdotla/dotenv#preload">dotenv ReadMe on GitHub</a>.</p><p>That’s it! I hope you prefer this way of managing your Google credentials. To me it seems much nicer than adding the required variable to your PATH, or referring to the credentials file by name.</p><p>This approach also means that your code will work automatically on any Google Cloud environment where the GOOGLE_APPLICATION_CREDENTIALS variables is defined by default, but will also work in your local environment without any actual code changes in your app.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=931b02ee2f91" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Storybook Decorators for Angular]]></title>
            <link>https://medium.com/@tanya/storybook-decorators-for-angular-5bb9e851d15f?source=rss-72d031eb1d0c------2</link>
            <guid isPermaLink="false">https://medium.com/p/5bb9e851d15f</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[storybook]]></category>
            <dc:creator><![CDATA[Tanya Gray]]></dc:creator>
            <pubDate>Sun, 29 Aug 2021 08:25:49 GMT</pubDate>
            <atom:updated>2021-08-29T08:29:27.380Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Creating a custom Storybook Decorator for Angular components<br>with Storybook v6 &amp; Angular v11</em></p><p>A <strong>decorator</strong> in Storybook is a <strong>function</strong> that can modify a story’s HTML, CSS and JavaScript to make it look or act differently from the default.</p><p>This article covers:</p><ul><li>Where to put your decorator code</li><li>How to write a decorator function</li><li>Applying a decorator to stories</li><li>Using custom parameters in decorators</li></ul><h3>Create a folder for your decorator</h3><p>I prefer to keep my custom Storybook decorators and add-ons within the .storybook folder of my Angular projects, so that it’s clear they are part of Storybook and not part of my application.</p><p>For a decorator called<strong> withCustomLayout</strong>, the folder structure and files would look similar to this:</p><pre>/.storybook<br>  /addons<br>    /addon-custom-layout<br>      index.js<br>      readme.md<br>  main.js<br>  manager.js<br>  preview.js<br>  tsconfig.json</pre><p>You may not have all the same Storybook configuration files as shown above, but you <em>will </em>need to create the folder .storybook/addons/addon-custom-layout and index.js within it. Remember to name the addon something sensible in case you ever decide to publish it!</p><h3>Write your decorator function</h3><p>All the code for your decorator will need to go in the new index.js file that you created for your addon.</p><p>This file should export a function that uses the <strong>makeDecorator</strong> function provided by Storybook to create the custom decorator.</p><pre>import { makeDecorator } from &quot;@storybook/addons&quot;;</pre><pre>export const withCustomLayout = makeDecorator({<br>  name: &#39;withCustomLayout&#39;,<br>  parameterName: &#39;customLayout&#39;,<br>  skipIfNoParametersOrOptions: true,<br>  wrapper: (getStory, context, { parameters }) =&gt; {<br>    // get a reference to the active story<br>    const story = getStory(context);</pre><pre>    // modify the story&#39;s content as a string<br>    const decoratedStory = `&lt;div&gt;${ story }&lt;/div&gt;`;</pre><pre>    // return the modified story string<br>    return decoratedStory;<br>  }</pre><pre>});</pre><p>The above decorator function simply adds a &lt;div&gt; wrapper around the original story, and returns the new story template as a string.</p><p>The parameterName is the property name you’ll use to enable this decorator for stories. The skipIfNoParametersOrOptions property is set to true so that the decorator will only be applied if a story has included the parameter customLayout in its parameters list.</p><p>In the Storybook docs, the makeDecorator examples use JSX in the wrapper function, because Storybook is built primarily for React. When using Angular, the story is just a plain JavaScript string that you can modify using whatever method you like.</p><p>The example above uses a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals">template string</a> `&lt;div&gt;${story}&lt;/div&gt;` but you could just as easily use string concatenation if that feels more familiar to you.</p><p>In a more complex example, you might also add an inline &lt;script&gt; or &lt;style&gt; block, which might look something like this:</p><pre>import { makeDecorator } from &quot;@storybook/addons&quot;;</pre><pre>export const withCustomLayout = makeDecorator({<br>  name: &#39;withCustomLayout&#39;,<br>  parameterName: &#39;customLayout&#39;,<br>  skipIfNoParametersOrOptions: true,<br>  wrapper: (getStory, context, { parameters }) =&gt; {<br>    // get a reference to the active story<br>    const story = getStory(context);</pre><pre>    // modify the story&#39;s content as a string<br>    const decoratedStory = `<br>      &lt;style&gt;<br>        .custom-wrapper {<br>          border: 2px solid red;<br>        }<br>      &lt;/style&gt;</pre><pre>      &lt;script&gt;<br>        console.log(&#39;custom script&#39;);<br>      &lt;/script&gt;</pre><pre>      &lt;div class=&quot;custom-wrapper&quot;&gt;<br>        ${ story }<br>      &lt;/div&gt;<br>    `;</pre><pre>    // return the modified story<br>    return decoratedStory;<br>  }</pre><pre>});</pre><h3>Register your decorator</h3><p>The easiest way to consume a custom decorator is to register it globally, then use a <strong>parameter</strong> to enable it for the story or stories where you’d like it to be applied.</p><p>To register the decorator globally, add it to the decorators array in your Storybook preview.js file. You can read more about preview.js under <a href="https://storybook.js.org/docs/react/configure/overview#configure-story-rendering"><em>“Configure story rendering”</em></a> in the Storybook docs.</p><p>If you don’t have the preview.jsfile, you’ll need to create it. Storybook automatically reads this file and applies the settings it finds there.</p><pre>// .storybook/preview.js</pre><pre>import { withCustomLayout } from &#39;./addons/addon-custom-layout&#39;;</pre><pre>export const decorators = [<br>  withCustomLayout<br>];</pre><p>The customLayout decorator will now be available on all stories, and will be activated if the story’s parameters include the customLayout param.</p><h3>Apply your decorator to a story</h3><p><a href="https://storybook.js.org/docs/react/writing-stories/parameters">Storybook parameters</a> can be set at the level of a single story, a group of stories (a component), or globally. The parameters are inherited, so setting a parameter at a higher level will flow down to each story.</p><p>To apply your decorator to a single story, add the customLayout parameter to the story’s parameters:</p><pre>export const Primary = Template.bind({});<br>Primary.args = {<br>  primary: true,<br>  label: &#39;Button&#39;,<br>};<br>Primary.parameters = {<br>  customLayout: true,<br>};</pre><p>See the <a href="https://storybook.js.org/docs/react/writing-stories/parameters">Storybook docs about parameters</a> for more information on how to apply parameters at different levels.</p><p>With the customLayout parameter set, your decorator should be working!</p><h3>Using parameters to configure a decorator</h3><p>In the example above, the parameters set customLayout: true so that the decorator will be applied. In the makeDecorator function we configured the decorator with skipIfNoParametersOrOptions: true. Because of this setting, a story only requires the customLayout property to be set to <em>something</em> — doesn’t matter what it’s set to.</p><p>If the customLayout parameter is set to a more complex object, then that object can be accessed inside the decorator function. This is how you can configure your decorator to apply changes to a story based on parameters which can be different for each story.</p><p>For example, a story using the decorator could configure a color property for the customLayout parameter:</p><pre>export const Primary = Template.bind({});<br>Primary.args = {<br>  primary: true,<br>  label: &#39;Button&#39;,<br>};<br>Primary.parameters = {<br>  customLayout: {<br>    color: &#39;blue&#39;,<br>  },<br>};</pre><p>This color property can then be accessed in the decorator function, and applied to the story:</p><pre>import { makeDecorator } from &quot;@storybook/addons&quot;;</pre><pre>export const withCustomLayout = makeDecorator({<br>  name: &#39;withCustomLayout&#39;,<br>  parameterName: &#39;customLayout&#39;,<br>  skipIfNoParametersOrOptions: true,<br>  wrapper: (getStory, context, { parameters }) =&gt; {<br>    // get a reference to the active story<br>    const story = getStory(context);</pre><pre>    // get the color from the story parameters<br>    // with a fallback to blue as default<br>    const color = parameters.color || &#39;blue&#39;;</pre><pre>    // modify the story&#39;s content as a string<br>    const decoratedStory = `<br>      &lt;style&gt;<br>        .custom-wrapper {<br>          border: 2px solid ${color};<br>        }<br>      &lt;/style&gt;</pre><pre>      &lt;script&gt;<br>        console.log(&#39;custom script&#39;);<br>      &lt;/script&gt;</pre><pre>      &lt;div class=&quot;custom-wrapper&quot;&gt;<br>        ${ story }<br>      &lt;/div&gt;<br>    `;</pre><pre>    // return the modified story<br>    return decoratedStory;<br>  }</pre><pre>});</pre><p>Note how the above decorator function pulls the value color from the parameters, and includes a fallback in case a color has not been provided. The color is then used in the CSS to set the border color.</p><p>With parameters it becomes very easy to create complex decorator functions that are able to adapt to the individual needs of each story or component.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5bb9e851d15f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular library: Module not found error]]></title>
            <link>https://medium.com/@tanya/angular-library-module-not-found-error-527445d44019?source=rss-72d031eb1d0c------2</link>
            <guid isPermaLink="false">https://medium.com/p/527445d44019</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[libraries]]></category>
            <category><![CDATA[ngfactory]]></category>
            <category><![CDATA[error]]></category>
            <dc:creator><![CDATA[Tanya Gray]]></dc:creator>
            <pubDate>Tue, 12 Nov 2019 19:17:02 GMT</pubDate>
            <atom:updated>2023-04-10T09:12:02.433Z</atom:updated>
            <content:encoded><![CDATA[<p>Making a quick note of this, because figuring it out took me far too long…</p><p>This project is an Angular app and Angular library in one project. The app consumes the library directly, not via npm.</p><p>The app uses the paths in tsconfig to configure importing of the lib:</p><pre>// root tsconfig.json<br>{<br>  &quot;compilerOptions&quot;: {<br>    ...<br>    &quot;paths&quot;: {<br>      &quot;@mycompany/my-library&quot;: [&quot;dist/my-library&quot;],<br>      &quot;@mycompany/my-library/*&quot;: [&quot;dist/my-library/*&quot;]<br>    }<br>  }<br>}</pre><p>This configuration works for ng serve but fails for ng build --prod with the following error:</p><pre>ERROR in ./dist/my-library/my-library.ngfactory.js<br>Module not found: Error: Can&#39;t resolve &#39;my-library&#39; in &#39;/Users/tanya.gray/Projects/my-project/dist/my-library&#39;</pre><p>Thanks to a teeny tiny comment on a GitHub issue, I realised the cause.</p><figure><img alt="alan-agius4 commented on 19 Jun 2018 • Indeed it is paramount to set the name inside the package.json to the actual library" src="https://cdn-images-1.medium.com/max/1024/1*3P3QnaQ8mHMvJlaFyC-uUA.png" /><figcaption>Thanks so much alan-agius4!</figcaption></figure><p>The error occurred because the library name I used for “paths” in the root tsconfig did not match the “name” in the library’s package.json file. My paths included the scope prefix, while the library name did not.</p><p>I updated the package.json in the library so that the package name was the same as the one used in the root tsconfig:</p><pre>// my-library package.json<br>{<br>  &quot;name&quot;: &quot;my-library&quot;,<br>  ...<br>}</pre><p>Changed to:</p><pre>// my-library package.json<br>{<br>  &quot;name&quot;: &quot;@mycompany/my-library&quot;,<br>  ...<br>}</pre><p>After rebuilding the library, then rebuilding the app, the error was resolved.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=527445d44019" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bundle Material Icons Font in Angular]]></title>
            <link>https://medium.com/@tanya/bundle-material-icons-font-in-angular-94e8e60afdd5?source=rss-72d031eb1d0c------2</link>
            <guid isPermaLink="false">https://medium.com/p/94e8e60afdd5</guid>
            <dc:creator><![CDATA[Tanya Gray]]></dc:creator>
            <pubDate>Sun, 24 Feb 2019 20:37:12 GMT</pubDate>
            <atom:updated>2019-02-24T20:37:12.951Z</atom:updated>
            <content:encoded><![CDATA[<p>Install the fonts via npm:</p><pre>npm i -S material-icons-font</pre><p>Add the font stylesheet to angular.json:</p><pre>&quot;styles&quot;: [<br>  &quot;src/styles.css&quot;,<br>  &quot;node_modules/material-icons-font/material-icons-font.css&quot;<br>],</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94e8e60afdd5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Configuring Angular Routes as a Module]]></title>
            <link>https://medium.com/@tanya/configuring-angular-routes-as-a-module-6b8944b78c24?source=rss-72d031eb1d0c------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b8944b78c24</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Tanya Gray]]></dc:creator>
            <pubDate>Wed, 17 Oct 2018 01:36:05 GMT</pubDate>
            <atom:updated>2018-10-17T01:37:20.761Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>app/app-routing.module.ts</strong>:</p><pre>import { NgModule } from &#39;@angular/core&#39;;<br>import { Routes, RouterModule } from &#39;@angular/router&#39;;<br>import { SignInComponent } from &#39;app/sign-in/sign-in.component&#39;;</pre><pre>const routes: Routes = [</pre><pre>  // lazy-loaded route, a module with its own sub-routes<br>  {<br>    path: &#39;admin&#39;,<br>    loadChildren: &#39;./reports/reports.module#AdminModule&#39;,<br>  },</pre><pre>  // component route, to show a specific component<br>  {<br>    path: &#39;sign-in&#39;,<br>    component: SignInComponent,<br>  },</pre><pre>  // default route, to redirect somewhere<br>  {<br>    path: &#39;**&#39;,<br>    redirectTo: &#39;sign-in&#39;,<br>  }</pre><pre>];</pre><pre>@NgModule({<br>  imports: [RouterModule.forRoot(routes)],<br>  exports: [RouterModule]<br>})<br>export class AppRoutingModule { }</pre><p>app/app.module.ts:</p><pre>import { NgModule } from &#39;@angular/core&#39;;<br>import { BrowserModule } from &#39;@angular/platform-browser&#39;;<br>import { AppComponent } from &#39;./app.component&#39;;<br>import { AppRoutingModule } from &#39;./app-routing.module&#39;;</pre><pre>@NgModule({<br>  imports: [<br>    BrowserModule,<br>    AppRoutingModule,<br>  ],<br>  declarations: [ AppComponent ],<br>  bootstrap:    [ AppComponent ]<br>})<br>export class AppModule { }</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b8944b78c24" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What the heck is npm?]]></title>
            <link>https://medium.com/@tanya/what-the-heck-is-npm-b8168f61e3b5?source=rss-72d031eb1d0c------2</link>
            <guid isPermaLink="false">https://medium.com/p/b8168f61e3b5</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[node]]></category>
            <category><![CDATA[npm]]></category>
            <dc:creator><![CDATA[Tanya Gray]]></dc:creator>
            <pubDate>Mon, 02 Jul 2018 03:34:10 GMT</pubDate>
            <atom:updated>2018-07-02T03:34:10.305Z</atom:updated>
            <content:encoded><![CDATA[<p>npm is confusing, that’s what. If you’re only just venturing beyond HTML and CSS (and maybe some jQuery) then npm is a bit of a jump! Here’s the basics…</p><h4>What is npm and what are packages?</h4><p>The letters npm stand for “node package manager”. When you are working on a JavaScript project, you can use npm to install other people’s code packages into your own project. Your project might be a web project like a website or web app, or it could be a server-side project using node. Any JavaScript project can use npm to pull in packages of existing code.</p><p>npm is a tool you install on your computer. It’s part of node, so <a href="https://nodejs.org/en/">install the LTS version of Node</a> to get both the node and npm commands in your command line. It must be installed on every computer where you want to work on your project, so if you move your files around using a USB drive don’t forget that part!</p><p>You use npm from the command line to install, uninstall or update packages. By “package” I mean any piece of code which someone has chosen to publish on npm.</p><p>Some examples of npm packages are:</p><ul><li>Angular</li><li>React</li><li>jQuery</li><li>Express</li><li>Socket.io</li></ul><p>There are thousands of packages published on npm. You can browse them on <a href="http://npmjs.com/">npmjs.com</a>, but usually you will find recommended packages by searching on Google or following blog posts. Some packages are only suitable for web projects, and some are only suitable for node projects.</p><h4><strong>Using npm in a project</strong></h4><p>To use npm packages in a project, your project must contain a file called package.json. This file keeps a list of all the packages you are using, and which version of each one you have chosen to use.</p><p><strong><em>If your file does not have a </em></strong><strong><em>package.json</em></strong><em> </em>then you can create one from the command line by running npm init inside your project.</p><pre>cd my-awesome-project<br>npm init</pre><p>Accept all the default settings when it asks questions, and once you’re done a new package.json file will be in your project.</p><p><strong><em>If your file does already have a </em></strong><strong><em>package.json</em></strong><em> </em>then you are already set up to use npm in your project.</p><h4>Installing packages</h4><p>Each time you open your project on a different computer, you may have to reinstall all your packages. This is especially true if you are moving between Mac and Windows. This is because not all packages are cross-compatible, and sometimes need a version downloaded for the specific system you are using it on.</p><p>When you open a project for the first time or on a different computer, reinstall all your packages:</p><pre>cd my-awesome-project<br>npm install</pre><p>After running npm install there will be a new folder in your project called node_modules. This folder contains all the code for all the packages you have installed. It also contains all that packages that your packages installed. It can get pretty big.</p><p>Here’s a programmer joke you can now consider yourself “in on”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*_idrQTtuzro1xmfoAu3RRg.jpeg" /></figure><p>To install a new package, use the command npm install followed by the name of the package. Include the --save flag to ensure the library is added to your package.json so you can install or update it again later:</p><pre>npm install that-cool-thing --save</pre><p>If everything explodes and you don’t understand the errors and you don’t know what to do, first try deleting your node_modules folder and then running a fresh npm install. You’ll get the hang of it, don’t panic!</p><p>Best of luck to you :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b8168f61e3b5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NgRx Effects: Stop Mapping Your Payload!]]></title>
            <link>https://medium.com/@tanya/ngrx-effects-stop-mapping-your-payload-958f37f2a809?source=rss-72d031eb1d0c------2</link>
            <guid isPermaLink="false">https://medium.com/p/958f37f2a809</guid>
            <category><![CDATA[ngrx]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[rxjs]]></category>
            <dc:creator><![CDATA[Tanya Gray]]></dc:creator>
            <pubDate>Thu, 15 Feb 2018 02:46:00 GMT</pubDate>
            <atom:updated>2018-02-15T02:46:00.966Z</atom:updated>
            <content:encoded><![CDATA[<p><em>… if you want :)</em></p><p>With NgRx 5 you can provide an action class to the ofType operator to get a strongly typed payload without using map. You can also use ofType as a pipeable operator.</p><pre>@Effect()<br>public loadAllData$: Observable&lt;Action&gt; = this.actions$.pipe(<br>  ofType&lt;LoadAction&gt;( ActionTypes.Load ),<br>  concatMap( loadAction =&gt; [<br>    new LoadUserData( loadAction.payload.userId ),<br>    new LoadGroupData( loadAction.payload.groupId )<br>  ])<br>);</pre><p>This is how it might have been done previously:</p><pre>@Effect()<br>public loadAllData$: Observable&lt;Action&gt; = this.actions$<br>  .ofType(ActionTypes.Load),<br>  .map( action: LoadAction) =&gt; action.payload )<br>  .concatMap( payload =&gt; [<br>    new LoadUserData( payload.userId ),<br>    new LoadGroupData( payload.groupId )<br>  ]);</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=958f37f2a809" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>