<?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: RomanRSN</title>
    <description>The latest articles on DEV Community by RomanRSN (@romanrsn).</description>
    <link>https://dev.to/romanrsn</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%2Fuser%2Fprofile_image%2F838851%2F878da70c-f16c-49e6-85a0-4e7a963b3fca.png</url>
      <title>DEV Community: RomanRSN</title>
      <link>https://dev.to/romanrsn</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/romanrsn"/>
    <language>en</language>
    <item>
      <title>Problem using Observable in the component, Async, trackBy, how to update a list</title>
      <dc:creator>RomanRSN</dc:creator>
      <pubDate>Tue, 29 Mar 2022 16:16:08 +0000</pubDate>
      <link>https://dev.to/romanrsn/problem-using-observable-in-the-component-async-trackby-how-to-update-a-list-1p95</link>
      <guid>https://dev.to/romanrsn/problem-using-observable-in-the-component-async-trackby-how-to-update-a-list-1p95</guid>
      <description>&lt;p&gt;Hi all,&lt;br&gt;
as I saw in many tutorials, it is highly recommended to use native way of Angular if we are dealing with an observable service.&lt;/p&gt;

&lt;p&gt;So I have a service like "ActionService" with a method:&lt;br&gt;
`  findAll(): Observable {&lt;br&gt;
    return this.http.post(this.baseUrl)&lt;br&gt;
  }&lt;/p&gt;

&lt;p&gt;My Component:&lt;br&gt;
export class ActionCodesComponent {&lt;br&gt;
    actionCodes$: Observable&lt;/p&gt;

&lt;p&gt;constructor(private actionService: ActionService) {&lt;br&gt;
    this.actionCodes$ = this.actionService.findAll();&lt;br&gt;
  }&lt;/p&gt;

&lt;p&gt;onDelete() { // how should I refresh the Observable here???&lt;br&gt;
    this.actionCodes$ = this.actionService.findAll();&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;trackByActionCode(index, actionCode): string {&lt;br&gt;
    return actionCode ? actionCode.id : undefined&lt;br&gt;
  }&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;The Problem:&lt;br&gt;
right now, if I delete an element from a list by clicking on "X" span, the whole list is being rendered again and flicking. So at first the trackBy function does not work (if I use the same function not with observable but with array of elements, it works very fine).&lt;br&gt;
Second: How can I update my Observable without recreation it again like this.actionCodes$ = this.actionService.getAll()?&lt;br&gt;
All examples on youtube and internet showing like myObservable = the Subject() and myObservable.next().&lt;br&gt;
But it does bot work with my Observable this.actionCodes$. There is no next() method available at all.&lt;/p&gt;

&lt;p&gt;Can somebody tell me what I am doing wrong here? If I cannot update a list using Observable (not an array), why it is recommended by every Angular expert?&lt;br&gt;
Thanks&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
