<?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 Ugur Meydanlı on Medium]]></title>
        <description><![CDATA[Stories by Ugur Meydanlı on Medium]]></description>
        <link>https://medium.com/@meydanliugur?source=rss-27759acb5e0a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dDfH2n_o5nxMmY_TkNhUJQ.jpeg</url>
            <title>Stories by Ugur Meydanlı on Medium</title>
            <link>https://medium.com/@meydanliugur?source=rss-27759acb5e0a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 07:12:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@meydanliugur/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[Angular NgRx , State Management]]></title>
            <link>https://medium.com/@meydanliugur/angular-ngrx-state-management-d0438482d1d?source=rss-27759acb5e0a------2</link>
            <guid isPermaLink="false">https://medium.com/p/d0438482d1d</guid>
            <category><![CDATA[ngrx]]></category>
            <category><![CDATA[state-management]]></category>
            <category><![CDATA[ngrx-store]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Ugur Meydanlı]]></dc:creator>
            <pubDate>Thu, 08 Dec 2022 14:51:42 GMT</pubDate>
            <atom:updated>2022-12-09T12:57:36.498Z</atom:updated>
            <content:encoded><![CDATA[<h3>Angular NgRx , State Management</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nqst4a5kNiRjZUSksyp8Cg.png" /></figure><p>Merhabalar bu yazımda ise Angulardaki Ngrx ve State Management kavramlarından bahsedeceğim,</p><p>Öncelikle State Management’ten başlamak istiyorum ,State managementi anlamadan önce state kavramını anlamamız gerekir.</p><p><strong>State</strong>: Verinin o anki durumudur yani değeridir.</p><h3>State Management</h3><p>SPA teknolojilerinde tek ekranda yönettiğimiz verilerin bağlı bulundukları diğer ekranda takip edilip güncelleme işlemine denir.</p><blockquote>Componentler arası veri taşıyıp ekleme güncelleme ve silme işlemi yapılmasıdır, yani durum yönetimidir.</blockquote><p>NgRx Nedir ?</p><p>NgRx, Angular’da reaktif uygulamalar oluşturmak için bir çerçevedir. Angular tarafından state mamagement konusunu profesyonel bir şekilde yapabilmemizi sağlayan güçlü bir kütüphanedir. NGRX, Redux modelinden esinlenen bir kütüphane türüdür</p><p>💡</p><p><strong>Reaktif uygulamalar nelerdir? </strong><a href="https://www.reactivemanifesto.org/">Reaktif manifestoya</a><br>göre , reaktif başvurular şunlardır:</p><p><strong>Duyarlı </strong>— Mümkünse zamanında yanıt verir.</p><p><strong>Dirençli </strong>— Başarısızlık karşısında duyarlı kalır.</p><p><strong>Esnek </strong>— Bu girdilere hizmet vermek için tahsis edilen kaynakları artırarak veya azaltarak girdi hızındaki değişikliklere tepki verebilir.</p><p><strong>Mesaj Odaklı </strong>— Bileşenler arasında gevşek bağlantı, izolasyon ve konum şeffaflığı sağlayan bir sınır oluşturmak için eşzamansız mesaj geçişine güvenin.</p><blockquote>NgRx state management için bize yapıyı sağlayan profesyonel kütüphanedir</blockquote><p>NgRx, kütüphaneler sağladığı yapıları aşağıdadır:,</p><ul><li>Küresel ve Yerel durum yönetme,</li><li>Daha temiz bir bileşen mimarisini desteklemek için yan etkilerin izolasyonu,</li><li>Varlık toplama yönetimi,</li><li>Angular router ile entegrasyon,</li><li>Birçok farklı türde uygulama oluştururken geliştirici deneyimini geliştiren geliştirici araçları.</li></ul><h3>NgRx hangi sorunları çözer?</h3><p>Yüksek düzeyde, esas olarak iki ana senaryoyu çözer:</p><ul><li>Farklı bileşenler arasında veri paylaşımı</li><li>Verilerin yeniden kullanımı için küresel bir durum</li></ul><h3>Farklı bileşenler arasında Veri Paylaşımı</h3><p>Karmaşık bir web uygulamasında farklı bölümleriniz vardır. Şu senaryoyu hayal edin: Bir e-ticaret sitenizde bir ürün listeniz ve alışveriş sepetiniz var. e-ticaret sitenizde bu iki bölümü, muhtemelen farklı Angular modüllerinde, farklı bileşen ağaçlarıdır. Öğe listesinde, kullanıcı belirli bir öğeyi “Sepetime ekle” üzerine tıklar. Tıklamanın ardından ürün alışveriş sepetinde görünür.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*5gmovXa_TW5tl2b7Mi4SDA.png" /></figure><p>Bu ürün alışveriş sepetinin bileşenlerine nasıl giriyor? <em>Verilerinizi bu iki component </em>arasında değiştirmek gereklidir .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/1*Rb9PQ8t7ZKrWR81TQl4ikw.png" /></figure><h3>Verileri yeniden kullanmak için genel bir durum sağlayın</h3><p>Yukarıdaki örnekte, aynı verileri iki kez yüklemek de istemezsiniz. Bu örnekte, alışveriş sepeti bileşenlerindeki resim, ürün başlığı ve fiyat gibi ürün verilerini yeniden kullanmak istiyorsunuz, değil mi? Yani ortak bir veri deposuna, küresel bir duruma ihtiyaç var.</p><p>NgRx, aşağıdaki şekilde gösterildiği gibi bu mağazayı yönetmek için küresel bir mağaza ve mağaza çevresinde Eylemler, Azaltıcılar, Seçiciler ve Efektler gibi çeşitli yapı taşları sağlar:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*rzigbbvm4C41Ct6u8QHALg.png" /></figure><p>Aşağıdaki çizim, NgRx’in ana yapı taşları arasındaki bağlantıları göstermektedir:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fcGRxD1mMyFGhNd7bHFlCA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/0*Ql5CFCC3FpRfJg45.jpg" /></figure><h3>Flux Pattern Nedir?</h3><p>Flux Pattern, yukarıdaki şemada görüldüğü üzere view’de olabilecek herhangi bir state değişikliğini ifade eden action isimli talimatı dispatcher’a göndererek, onun aracılığıyla store’lara bildirmektedir.</p><p>Dispatcher; ise kendinde tanımlı olan tüm store’lara gelen action’ı yayınlamakla görevlidir ve state’de yapılan değişikliğe dair haber almalarını sağlamaktadır. Yani, yayınlanan action, dispatcher’a gönderilmektedir.</p><h3>Action ve Store Nedir?</h3><p>Action; state’de yapılan değişikliği tarif edecek olan gövdeyi barındıran bir talimattır. Yapısı aşağıdaki gibidir;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/438/0*5ubMdxalhwmEts13.png" /></figure><ul><li>Store; state’in tutulduğu yapılardır. Store’da, ilgili state’e dair bir değişiklik yapılacaksa bu sorumluluğu Reducer isimli fonksiyonlar üstlenmektedir. Bu fonksiyonları yazımızın ilerleyen satırlarında ele alıyor olacağız…</li></ul><p>Yukarıdaki döngü işlediği an, state’de değişiklik gerçekleşecek ve artık ilgili state’i kullanan tüm view’lerin haberdar edilmesi gerekecektir. Haliyle bu işlemi de Controller View ismini verdiğimiz mekanizma üstlenecektir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/0*kqDRHUcB93V_-NnJ.png" /></figure><p>Controller View, yandaki şema da görüldüğü üzere uygulamadaki tüm view’ler ile haberleşen bir nesnedir. Eğer ki store’da herhangi bir state verisinde bir değişiklik olursa buna göre view’leri render edecektir.</p><p>İşte Flux Pattern bu şekilde bir mantıkla uygulanmaktadır. Dikkat ederseniz eğer uygulama yapısı büyüdükçe ve uygulamanın kompleksitesi arttıkça bu pattern’ın uygulanması zorlaşmaktadır. Çünkü birden fazla store’un kullanılması, zamanla uygulama büyüklüğüyle doğru orantılı bir şekilde birbirlerine bağımlı olabilmelerine sebep olmakta ve bunların orkestra edilmesi git gide zorlaşmaktadır.</p><p>Bu noktada bu pattern’in daha rahat uygulanmasını sağlayan Redux karşımıza çıkmaktadır.</p><h3>Redux Nedir?</h3><p>Angular gibi JavaScript temelli uygulamalarda State Management süreçlerini basitleştirmek için kullanılan pattern’dır. Temel olarak Single source of truth​, State is read-only​ ve Changes are made with pure functions​ olmak üzere üç ilkeye dayanmaktadır. Direkt ilkeleri izah etmemiz gerekirse eğer;</p><ul><li>Single source of truth​: Tek doğru kaynak​<br>Uygulamada state’in tek bir store’da tutulmasını ifade etmektedir.</li><li>State is read-only: Salt-okunur durum<br>Store’da ki mevcut state verilerinin değişmezliğini ifade eder. Yani, state’de olan değişiklik o anki store’da ki veri üzerinde değil, onun klonlanmış hali üzerinde uygulanmalıdır.</li><li>Changes are made with pure functions:​ Değişiklikler saf fonksiyonlarla yapılır<br>Store’lar üzerindeki değişikliklerin sadece o işe odaklanmış reducer ismini verdiğimiz fonksiyonlar ile yapılmasını ifade eder.</li><li>Redux pattern’ın çalışma mantığı nasıldır?<br>Redux pattern’ın çalışma mantığını anlayabilmek için aşağıdaki görsel şemayı incelememizde fayda var.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*a5KDtmLT5nmsRL0X.png" /></figure><p>Şemadan görüldüğü üzere, UI’da(view’de) herhangi bir state değişikliği söz konusu olduğunda bu değişikliği temsil eden bir action fırlatılmakta ve fırlatılan bu action’ı reducer fonksiyonu ile yakalayarak yapılan değişiklik algılanmakta ve store’da ki mevcut state yerine gerekli güncellemelerin yapıldığı yeni state oluşturularak, store’a gönderilmektedir. Bu işlem neticesinde, store’da yenilenen state verisi ilgili tüm view’ler tarafından güncellenmiş olacaktır.</p><h3>Actions Nedir?</h3><p>Actions, web uygulamanızı kullanırken meydana gelen benzersiz olayları ifade eder. Bunlar, belirli bir sayfayla kullanıcı etkileşimi veya ağ istekleri yoluyla harici etkileşim veya örneğin cihaz API’si ile doğrudan etkileşim olabilir.</p><p>Actions, NgRx’te Mağaza aracılığıyla gönderilir ve NgRx’in reducers ve effects tarafından gözlemlenir.</p><p>NgRx actions aşağıdaki gibi tanımlayabilirsiniz:</p><pre>import {createAction, props} from &#39;@ngrx/store&#39;;<br>import {Item} from &quot;../model/items.model&quot;;</pre><pre>export const getItems = createAction(<br>  &#39;[Item List] Get items&#39;);<br>export const addToCart = createAction(<br>  &#39;[Item List] Add item to cart&#39;,<br>  props&lt;{ item: Item }&gt;()<br>);</pre><p>Actions’ u gruplandırmak için NgRx , Action Group Creator tanıttı . Yukarıdaki örnek, basmakalıp kodu azaltmak için Action Group Creator ile yeniden yazılabilir.</p><p>Actions bir ActionGroup ile gruplandırma:</p><pre>export const ItemListActions = createActionGroup({<br>  source: &#39;Item List&#39;,<br>  events: {<br>    &#39;Get Items&#39;: emptyProps(),<br>    &#39;Add To Cart&#39;: props&lt;{item: Item}&gt;(),<br>  }<br>});</pre><h3>Store Nedir?</h3><p>Store , NgRx’in en önemli bileşenidir. Global, uygulama çapında bir durumu ifade etmek için tek bir mağaza sağlar.<br>Dosya , tek bir değişmez veri yapısına dayanır. Dosya ayrıca belirli durum verilerini almak için optimize edilmiştir.</p><p>Store deposuna erişmek için , basitçe enjekte edebilirsiniz. Store’da , seçicileri veya gönderme eylemlerini kullanarak verileri seçebilirsiniz.</p><p>İşlemleri store aracılığıyla gönderme:</p><pre>import {Store} from &quot;@ngrx/store&quot;; <br>import {getItems} from &quot;../../actions/items-page.actions&quot;;</pre><pre>this.store.dispatch(getItems());</pre><h3>Reducers Nedir?</h3><p>Reducers, mağazanızdan durum geçişlerinden sorumludur. Harika olan şey, indirgeyicilerin saf fonksiyonlar olmasıdır, yani belirli bir girdi için aynı çıktıyı üretirler.</p><p>Bir reducer ile durum geçişi:</p><pre>export const itemsReducer = createReducer(  <br> initialState,<br>   on(itemsLoadedSuccessfully, (store, result) =&gt; ({ <br>    ...store,     items: result.data  <br> })) <br>);</pre><h3>Selectors Nedir?</h3><p>Selectors size bir mağaza durumunun dilimlerini verir. Ayrıca farklı selectors oluşturmanıza da yardımcı olurlar.</p><p>Store’dan veri seçmek için bir reducer sağlayın:</p><pre>export const selectItemsState = (state: ShopState) =&gt; state.itemsFeature;</pre><pre>export const selectItems = createSelector(<br>  selectItemsState,<br>  (itemsFeature: ItemsFeatureState | undefined) =&gt; {<br>    return itemsFeature?.items;<br>  }<br>);</pre><p><strong>Bir işaretlemede bir selectors’dan gelen veriler nasıl bağlanır?</strong></p><p><a href="https://ngrx.io/guide/component">@ngrx/component</a> paketi ile *ngrxLet adlı bir yönerge alırsınız. Bu direktif ile verileri kolayca bağlayabilirsiniz.</p><pre>&lt;ng-container *ngrxLet=&quot;number$ as n&quot;&gt;<br>  &lt;app-number [number]=&quot;n&quot;&gt;&lt;/app-number&gt;<br>&lt;/ng-container&gt;</pre><h3>Effects Nedir?</h3><p>Effects, store için RxJS tabanlı bir yan etki modelidir. Efektler, eylemler için yeni kaynaklar sağlamak üzere akışları kullanır. Etkiler, yan etkileri bileşenlerden ayırır. Bu bize durumu seçen ve eylemleri gerçekleştiren “daha saf” bileşenler verir.</p><pre>loadArticles$ = createEffect(() =&gt; this.actions$.pipe(<br>      ofType(getItems),<br>      mergeMap(() =&gt; this.articleService.getItems()<br>        .pipe(<br>          map(items =&gt; (itemsLoadedSuccessfully({data: items}))) <br>        ))<br>    )<br>  );</pre><h3>Sonuç</h3><p>Bu yazımda sizlere NgRx ile state management hakkında bilgiler verdim umarım aklınızdaki sorulara cevap vermişimdir şimdiden iyi okumalar diliyorum. Daha falza bilgi almak için ekleyeceğim kaynaklardan bilgi alabilirsiniz.</p><p><a href="https://ngrx.io/docs">https://ngrx.io/docs</a></p><ul><li><a href="https://www.workingsoftware.dev/what-is-ngrx-and-why-is-it-used-in-angular/">What is NgRx and why is it used in Angular apps?</a></li><li><a href="https://itnext.io/ngrx-best-practices-for-enterprise-angular-applications-6f00bcdf36d7">NgRx — Best Practices for Enterprise Angular Applications</a></li></ul><p><a href="https://youtu.be/0bt4kQlsKgA">https://youtu.be/0bt4kQlsKgA</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d0438482d1d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular Rxjs Nedir ?]]></title>
            <link>https://medium.com/@meydanliugur/angular-rxjs-nedir-67742573a1ce?source=rss-27759acb5e0a------2</link>
            <guid isPermaLink="false">https://medium.com/p/67742573a1ce</guid>
            <category><![CDATA[operators]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[rxjs]]></category>
            <category><![CDATA[subject]]></category>
            <category><![CDATA[scheduler]]></category>
            <dc:creator><![CDATA[Ugur Meydanlı]]></dc:creator>
            <pubDate>Sat, 26 Nov 2022 22:50:33 GMT</pubDate>
            <atom:updated>2022-11-27T17:03:32.860Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Angular Rxjs Nedir ?</strong></h3><p>Merhabalar, Bu yazımda SPA(Single Page Application) uygulamalarda olayları yönetebilmek için oldukça kullanışlı olan RxJS kütüphanesini Angular teknolojisiyle a’dan z’ye tüm detaylarıyla inceliyor olacağız</p><p>Öncelikle,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gAYdzhkJe-_ikfr6ljaczA.jpeg" /></figure><h3>Reaktif Programlama Nedir</h3><p>Reaktif programlama, asenkron veri süreçleriyle süreçleri oluşturma ilkesi edinen bir programlama paradigmasıdır.</p><p>OOP(Object Oriented Programming) ile Reaktif Programlama arasındaki fark nedir ?</p><ul><li>OOP ile yazılımlar, gerçek hayattaki olguları uygulama ile modelleyerek tasarlanmaktadır.</li><li>Reaktif Programlamada gerçek hayattaki olaylar baz alınarak işlemleri tasarlandı.</li></ul><pre>let a= 5<br>let b= 6<br>let c=a+b <br></pre><ul><li>Prosedürel programlama mantığına göre c değişkenine atanmış a ve b değerleri hesaplamalarından sonra değişikliklerse bu değişiklik c değişkenini etkilemez</li><li>Çünkü ardışık işlemde c&#39;nin değeri tanımlanmış ve a ve b değişkeninden bağımsızdır.</li><li>Reaktif Programlamada a ve b değişkenlerinin açıklamaları durumdaki sonuç yani c değişkeninin değeri de buna göre şekillenecektir.</li></ul><p>Rxjs&#39;de veriler parça parça almamızı sağlayan bu yapıyı inceleyelim.</p><h3>Rxjs Nedir ?</h3><p>Javascript kodlarında Reaktif Kodlama yaptıklarını Sağlayan çalışan işlevleri sunan bir kütüphanedir. Rxjs olay ve veri yararları abone olunabilir (subscription), nesneye (observable) nesneye dönüştürüp, bunlar üzerinde operatörler dönüşümler/etkiler gerçekleştirebilmesini ve sonucu elde edilmesini/tüketmemizi sağlayan JavaScipt ile yazılan Reaktif Programlama kütüphanesidir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*22m9TDpjyZBDuJCNq3bX2w.png" /></figure><h3>Observable Nedir?</h3><p>Rxjs, Reaktif programlamayı observable nesnesi sayesinde gerçekleştirmektedir. Süreçte dönüşüme uğrayacak dataların akışını sağlayan nesnedir. Kısacası oluşturulan veri akışıdır. Akışı tüketmek amacıyla her Observable’da bir subscribe(Abonelik) metodu bulunur.</p><h3>Observer Nedir ?</h3><p>Observable nesnesindeki akışı izleyen/tükeyen fonksiyonlardır. Elimizdeki herhangi bir observable’yi tüketebilmek için kullanılan subscribe olan fonksiyona Observer fonksiyonu diyoruz.</p><p>Akışı izleme olayına Subsciption (Abonelik ) denir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*KC814QNcCIMRrX-alxkgUA.png" /></figure><h3>Subscription Nedir ?</h3><p>Subscription( Abonelik), tek kullanımlık bir kaynağı, genellikle bir Observable’in yürütülmesini temsil eden bir nesnedir. Örnek verecek olursak bir dokunuşla akmaya başlayan musluk gibi düşünebilirsin. Birinin sadece musluğu kapatması lazım. Musluktan su akışının gözlenebilir(observable) yapılması rolü aboneye(subscriber) aittir.</p><h3>Subject Nedir ?</h3><p>Birden fazla Observer’in bir observable’a abone olması durumudur. Bir observable’ı birden fazla observer kullanıyorsa buna Subject diyoruz. Özelleştirilmiş Observable gibi düşünebiliriz.</p><h3>Subject Türleri Nelerdir ?</h3><p><strong>Behaviorsubject </strong>: Akışa abone olan observer’ın akıştaki bir önceki veriden başlayarak gelen verileri almasını sağlar</p><p><strong>ReplaySubject</strong> : Akışa abone olan observer’ın akıştaki istediğimiz kadar öncesini almasını sağlar.</p><p><strong>AsyncSubject</strong> : Akıştaki son veriyi yani son değer almamızı sağlar. Akıştaki son verinin hangisi olduğunu anlayabilmesi için complete() fonksiyonun tetiklenmesini bekler.</p><h3>Scheduler Nedir?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/340/1*QryJ_rxwVpm7rnMduXop2w.png" /></figure><p>Bir aboneliğin ne zaman başlayacağını ve verinin ne zaman observer’lara iletileceğini kontrol eden bir nesnedir.</p><p><strong>3 Bileşenden oluşanlar Bunlar;</strong></p><p><strong>Execution Context</strong> : Görevin nerede ve ne zaman çalışacağını gösterir.</p><p><strong>Execution Policy</strong> : Belirli politikalara göre görevlerinin nasıl saklanacağı ve hangi sırayla alınacağından sorumludur.</p><p><strong>Clock</strong> : scheduler, new() fonksiyonuyla sanal olarak mevcut zaman bilgisinin alınmasını sağlar. Observer’lar bu zamansal bilgiye uyarak çalışırlar.</p><h3>Scheduler Türleri Nelerdir ?</h3><p><strong>tailScheduler :</strong> Yapılacak işi kuyruğa alır belli bir sıra ile arka arkaya çalıştırılacak işler için kullanılır.</p><p><strong>asapScheduler :</strong> Mikro tasklar için kullanılır. Mevcut işten sonra ve bir sonraki işten önce çalışır Asenkron dönüşümler için kullanılır.</p><p><strong>asyncScheduler :</strong> Zaman tabanlı işlemlerde kullanılır. SetTimeOut Fonksiyonu ile çalışır haliyle veriler observer’a asenkron iletilir.</p><p><strong>AnimationFrameScheduler :</strong> Browser&#39;in bir sonraki içeriği yeniden boyamadan önce tetiklenen scheduler türüdür.</p><h3>pipe Fonksiyonu Nedir ?</h3><p>Kod içerisinde yaygın olarak kullanılan birden fazla operatör dizisi varsa eğer pipe fonksiyonu kullanılabilir. İhtiyaca göre filtreleme, dönüştürülme gibi süreçlerden geçebilir. Örneğin observable ile oluşturulmuş herhangi bir işlemi veya işlemleri optimize etmek için birden çok operatör kullanılabilir.</p><h3><strong>Operatörler Nelerdir ?</strong></h3><p>Yaptıkları bir neticesinde sonuç olarak observable akış dönen ve bu akışa subscribe olunan operatörlerdir.</p><h3>Operatör Grupları:</h3><p>RxJs’te yaptıkları işlere göre operatörler on farklı şekilde gruplandırılabilir.</p><p><strong>Yaratma Operatörleri:</strong> Observable yaratmak için kullanılan operatörlerdir.</p><p><a href="https://rxjs-dev.firebaseapp.com/api/ajax/ajax">ajax</a> <a href="https://rxjs-dev.firebaseapp.com/api/index/function/bindCallback">bindCallback</a> <a href="https://rxjs-dev.firebaseapp.com/api/index/function/bindNodeCallback">bindNodeCallback</a> <a href="https://rxjs-dev.firebaseapp.com/api/index/function/defer">defer</a> <a href="https://rxjs-dev.firebaseapp.com/api/index/function/empty">empty</a> <a href="https://rxjs-dev.firebaseapp.com/api/index/function/from">from</a> <a href="https://rxjs-dev.firebaseapp.com/api/index/function/fromEvent">fromEvent</a> <a href="https://rxjs-dev.firebaseapp.com/api/index/function/fromEventPattern">fromEventPattern</a> <a href="https://rxjs-dev.firebaseapp.com/api/index/function/generate">generate</a> <a href="https://rxjs-dev.firebaseapp.com/api/index/function/interval">interval</a> <a href="https://rxjs-dev.firebaseapp.com/api/index/function/of">of</a> <a href="https://rxjs-dev.firebaseapp.com/api/index/function/range">range</a> <a href="https://rxjs-dev.firebaseapp.com/api/index/function/throwError">throwError</a> <a href="https://rxjs-dev.firebaseapp.com/api/index/function/timer">timer</a> <a href="https://rxjs-dev.firebaseapp.com/api/index/function/iif">iif</a></p><p><strong>Birleştirme ve Yaratma Operatörleri: </strong>Bu operatörler aynı zamanda birleştirme işlevine sahip Observable yaratan operatörlerdir.</p><p><a href="https://rxjs-dev.firebaseapp.com/api/index/function/combineLatest">combineLatest</a> <a href="https://rxjs-dev.firebaseapp.com/api/index/function/concat">concat</a> <a href="https://rxjs-dev.firebaseapp.com/api/index/function/forkJoin">forkJoin</a> <a href="https://rxjs-dev.firebaseapp.com/api/index/function/merge">merge</a> <a href="https://rxjs-dev.firebaseapp.com/api/index/function/race">race</a> <a href="https://rxjs-dev.firebaseapp.com/api/index/function/zip">zip</a></p><p>Bu operatörler hakkında detaylı bilgi almak için aşağıdaki yazıyı okumanızı tavsiye ederim</p><p><strong>Dönüşüm operatörleri: </strong>Observable’dan yayılan değerleri yeni bir observable içinde dönüştüren operatörlerdir.</p><p><a href="https://rxjs-dev.firebaseapp.com/api/operators/buffer">buffer</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/bufferCount">bufferCount</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/bufferTime">bufferTime</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/bufferToggle">bufferToggle</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/bufferWhen">bufferWhen</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/concatMap">concatMap</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/concatMapTo">concatMapTo</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/exhaust">exhaust</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/exhaustMap">exhaustMap</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/expand">expand</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/groupBy">groupBy</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/map">map</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/mapTo">mapTo</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/mergeMap">mergeMap</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/mergeMapTo">mergeMapTo</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/mergeScan">mergeScan</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/pairwise">pairwise</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/partition">partition</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/pluck">pluck</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/scan">scan</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/switchMap">switchMap</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/switchMapTo">switchMapTo</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/window">window</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/windowCount">windowCount</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/windowTime">windowTime</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/windowToggle">windowToggle</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/windowWhen">windowWhen</a></p><p><strong>Filtreleme Operatörleri: </strong>Observable’dan yayılan değerleri filtrelemek için kullanılan operatörlerdir.</p><p><a href="https://rxjs-dev.firebaseapp.com/api/operators/audit">audit</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/auditTime">auditTime</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/debounce">debounce</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/debounceTime">debounceTime</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/distinct">distinct</a> <a href="https://rxjs-dev.firebaseapp.com/class/es6/Observable.js~Observable.html#instance-method-distinctKey">distinctKey</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/distinctUntilChanged">distinctUntilChanged</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/distinctUntilKeyChanged">distinctUntilKeyChanged</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/elementAt">elementAt</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/filter">filter</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/first">first</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/ignoreElements">ignoreElements</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/last">last</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/sample">sample</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/sampleTime">sampleTime</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/single">single</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/skip">skip</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/skipLast">skipLast</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/skipUntil">skipUntil</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/skipWhile">skipWhile</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/take">take</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/takeLast">takeLast</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/takeUntil">takeUntil</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/takeWhile">takeWhile</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/throttle">throttle</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/throttleTime">throttleTime</a></p><p><strong>Birleştirme Operatörleri: </strong>Bu operatörler hakkında detaylı örnek için “<em>Birleştirme ve Yaratma Operatörleri”</em> bölümünde verilen makaleyi okuyabilirsiniz.</p><p><a href="https://rxjs-dev.firebaseapp.com/api/operators/combineAll">combineAll</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/concatAll">concatAll</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/exhaust">exhaust</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/mergeAll">mergeAll</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/startWith">startWith</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/withLatestFrom">withLatestFrom</a></p><p><strong>Radyo yayını operatörleri (Multicasting): </strong>Bu ismi ben uydurdum ama en güzel tanım olduğunu düşünüyorum.</p><p><a href="https://rxjs-dev.firebaseapp.com/api/operators/multicast">multicast</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/publish">publish</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/publishBehavior">publishBehavior</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/publishLast">publishLast</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/publishReplay">publishReplay</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/share">share</a></p><p><strong>Hata Yakalama Operatörleri</strong>: <a href="https://rxjs-dev.firebaseapp.com/api/operators/catchError">catchError</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/retry">retry</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/retryWhen">retryWhen</a></p><p><strong>Yararlı operatörler:</strong> <a href="https://rxjs-dev.firebaseapp.com/api/operators/tap">tap</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/delay">delay</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/delayWhen">delayWhen</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/dematerialize">dematerialize</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/materialize">materialize</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/observeOn">observeOn</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/subscribeOn">subscribeOn</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/timeInterval">timeInterval</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/timestamp">timestamp</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/timeout">timeout</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/timeoutWith">timeoutWith</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/toArray">toArray</a></p><p><strong>Şartlı ve Boolean Operatörler: </strong><a href="https://rxjs-dev.firebaseapp.com/api/operators/defaultIfEmpty">defaultIfEmpty</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/every">every</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/find">find</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/findIndex">findIndex</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/isEmpty">isEmpty</a></p><p><strong>Matematiksel ve Kümeleme Operatörleri: </strong><a href="https://rxjs-dev.firebaseapp.com/api/operators/count">count</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/max">max</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/min">min</a> <a href="https://rxjs-dev.firebaseapp.com/api/operators/reduce">reduce</a></p><p>Bu listedeki operatörlerden sık kullanılanlara dair kısa bilgiler verilip örnek kodlar altına eklenecektir.</p><h3>concatMap</h3><p>Bu operatör, akışta aktif abonelik işlemi bitmeden bir sonrakini başlatmaz ve veri kaynağındaki sıraya göre bir akış sağlar. Bu nedenle, önceki verileri bir sonrakinde değişken olarak kullanmak mümkündür.</p><pre>import express from &quot;express&quot;;<br>import { of } from &quot;rxjs&quot;;<br>import { concatMap, delay, mergeMap } from &quot;rxjs/operators&quot;;<br><br>const opconcatmap = express.Router();<br><br>opconcatmap.route(&quot;/opconcatmap&quot;).get(async (req, res, next) =&gt; {<br>  // If order is important at getting data from source then concatMap is usefull<br>  const source = of(3000, 2000, 1000)<br>    .pipe(concatMap((val) =&gt; of(`Delayed by: ${val}ms`).pipe(delay(val))))<br>    .subscribe((val) =&gt; console.log(`With concatMap: ${val}`));<br>});<br><br>module.exports = opconcatmap;</pre><p>Çıktı:</p><pre>With concatMap: Delayed by: 3000ms<br>With concatMap: Delayed by: 2000ms<br>With concatMap: Delayed by: 1000ms</pre><p>Gecikme işlemi verinin kaynaktaki sırasına göre olacağından ilk veri 3 saniye sonra, ikinci veri 2 saniye sonra ve son veri 1 saniye sonra yazdırılacaktır.</p><h3>filter Operatörü</h3><p>Akış tarafından yayılan değerleri <em>filtre</em> işleci ile filtreleyebilirsiniz. Bu filtre kuralı sizin belirlediğiniz bir kural olacaktır. Aşağıdaki örnekte <a href="https://swapi.dev/"><em>StarWars</em></a> sunucusundan gelen kişilerin boy bilgileri konsola yazdırılmaktadır. Filtreleme kuralı olarak 100&#39;den büyük olduğu belirlendi.</p><pre>import express from &quot;express&quot;;<br>import axios from &quot;axios&quot;;<br>import { from } from &quot;rxjs&quot;;<br>import { filter } from &quot;rxjs/operators&quot;;<br><br>const opfilter = express.Router();<br><br>opfilter.route(&quot;/opfilter&quot;).get(async (req, res, next) =&gt; {<br>  await axios.get(&quot;https://swapi.dev/api/people&quot;).then((result) =&gt; {<br>    const array = from(result.data.results);<br>    array<br>      .pipe(filter((val) =&gt; parseInt(val[&quot;height&quot;]) &gt; 100))<br>      .subscribe((val) =&gt; console.log(&quot;height: &quot; + parseInt(val[&quot;height&quot;])));<br>  });<br>});<br><br>module.exports = opfilter;</pre><h3>From Operatörü</h3><p>Bir diziden, dizi benzeri bir nesneden, bir Promise’den, yinelenebilir bir nesneden veya gözlemlenebilir benzeri bir nesneden bir Gözlenebilir oluşturur.</p><p>Gerçek bir akış için <em>/people Bitiş Noktası ile </em><a href="https://swapi.dev/"><em>https://swapi.dev/ adresinden</em></a><em> bazı veriler alıp from</em> ile gözlemlenebilir olarak yayınlayalım .</p><pre>import express from &quot;express&quot;;<br>import axios from &quot;axios&quot;;<br>import { from } from &quot;rxjs&quot;;<br><br>const opfrom = express.Router();<br><br>opfrom.route(&quot;/&quot;).get(async (req, res, next) =&gt; {<br>  await axios.get(&quot;https://swapi.dev/api/people&quot;).then((result) =&gt; {<br>    const array = from(result.data.results);<br>    array.subscribe((val) =&gt; console.log(val));<br>  });<br>});<br><br>module.exports = opfrom;</pre><p>Görüldüğü gibi gelen datayı <em>from ile gözlemlenebilir hale getirip .subscribe()</em> metodu ile abone olabiliyoruz.</p><p>Çıktı:</p><pre>{<br>  name: ‘Luke Skywalker’,<br>  height: ‘172’,<br>  …<br>}<br>{<br>  name: ‘C-3PO’,<br>  height: ‘167’,<br>  …<br>}<br>...</pre><h3>interval Operatörü</h3><p><em>Belirtilen her zaman aralığında</em> sıralı sayılar yayan bir gözlemlenebilir oluşturur.</p><pre>import express from &quot;express&quot;;<br>import { interval } from &quot;rxjs&quot;;<br><br>const opinterval = express.Router();<br><br>opinterval.route(&quot;/opinterval&quot;).get(async (req, res, next) =&gt; {<br>  //emit value in sequence every 1 second<br>  const source = interval(1000).subscribe((val) =&gt; console.log(val));<br>});<br><br>module.exports = opinterval;</pre><h3>map Operetörü</h3><p><em>Harita</em> operatörü ile <em>yinelenebilir</em> bir nesnenin her bir öğesini dönüştürebiliriz . Bu işleç, JavaScript’in .map() işlevine çok benzer <em>şekilde çalışır</em> . Fark şu ki; Mevcut bir dizideki öğeler üzerinde değil, akış sırasında elde edilen (gözlemlenebilirden yayılan) öğeler üzerinde değişiklik yapmaya yarar.</p><p>Aşağıdaki örnekte, sunucudan nesnenin bir alanı alınarak <em>tamsayı</em> değerine dönüştürülür ve buna 50 eklenir ve konsola yazdırılır.</p><pre>import express from &quot;express&quot;;<br>import axios from &quot;axios&quot;;<br>import { from } from &quot;rxjs&quot;;<br>import { map } from &quot;rxjs/operators&quot;;<br><br>const opMap = express.Router();<br><br>opMap.route(&quot;/&quot;).get(async (req, res, next) =&gt; {<br>  await axios.get(&quot;https://swapi.dev/api/people&quot;).then((result) =&gt; {<br>    const array = from(result.data.results);<br><br>    array<br>      .pipe(map((val) =&gt; parseInt(val[&quot;height&quot;]) + 50))<br>      .subscribe((val) =&gt; console.log(val));<br>  });<br>});<br><br>module.exports = opMap;</pre><p>Burada <strong>.pipe()</strong> yöntemi öne çıkıyor. Bu yöntemle birden fazla operatör virgülle ayrılarak kullanılabilir. Yani bir değer art arda birçok kez işlenebilir.</p><p><em>Harita</em> operatörü <em>observable</em> döndürdüğü için , <em>abone</em> olarak değeri aldığımızı da belirtelim .</p><h3>mergeMap Operatörü</h3><p><em>concatMap’ten</em> farklı olarak , <em>mergeMap</em> , veri kaynağındaki veri sırasına bakılmaksızın ve önceki veri işleminin tamamlanmasına dikkat etmeden tüm abonelikleri birbiri ardına hızlı bir şekilde eşler.</p><p>Bu nedenle, birleştirmeMap için en yaygın kullanım durumlarından biri, iptal edilmemesi gereken isteklerdir.</p><pre>import express from &quot;express&quot;;<br>import { of } from &quot;rxjs&quot;;<br>import { delay, mergeMap } from &quot;rxjs/operators&quot;;<br><br>const opmergemap = express.Router();<br><br>opmergemap.route(&quot;/opmergemap&quot;).get(async (req, res, next) =&gt; {<br>  // mergeMap handles the data without order unlike concatMap, in this case mergeMap result inner subscription without to wait previous datas ends And does it so fast<br>  const source = of(3000, 2000, 1000)<br>    .pipe(mergeMap((val) =&gt; of(`Delayed by: ${val}ms`).pipe(delay(val))))<br>    .subscribe((val) =&gt; console.log(`With mergeMap: ${val}`));<br>});<br><br>module.exports = opmergemap;</pre><p>Çıktısı:</p><pre>With mergeMap: Delayed by: 1000ms<br>With mergeMap: Delayed by: 2000ms<br>With mergeMap: Delayed by: 3000ms</pre><p>Konsolda da görüleceği üzere; bir önceki <em>subscription </em>sonucunu bir sonrakinde değişken olarak kullanmadığından ve sıralamaya dikkat edilmediğinden gecikme fonksiyonu iyi çalışmamaktadır</p><h3>of Operatörü</h3><p>Of operatörü <em>,</em> JavaScript’ten aşina olduğumuz <em>.map() işlevi gibi davranır. </em>Fark; bir diziniz olmasa bile, her türlü veriyi toplar ve <em>gözlenebilirleri</em> yayar . Örneğin, aşağıdaki gibi ilgisiz bazı verilerimiz olduğunu varsayalım.</p><pre>1 — “mike” — true — 4 — { country: “German” }</pre><p>Şimdi bu verileri bir dizinin elemanlarıymış gibi konsolda sırayla gösterelim:</p><pre>const source = of(1, “mike”, true, 4, { country: “German” });<br>const subscribe = source.subscribe((val) =&gt; <br> console.log(val)<br>);</pre><p>Çıktı:</p><pre>1<br>mike<br>true<br>4<br>{ country: ‘German’ }</pre><h3>retryWhen and delayWhen Operetörler</h3><p>Adından da anlaşılacağı üzere stream sırasında belirlenen bir duruma göre bir hata atıldığında bu hata <em>retryWhen</em> içinde yakalanır ve ilgili fonksiyon tekrar çalıştırılır. <em>delayWhen</em> ile bu hata durumlarında stream belli bir süre bekletilebilir. Aşağıda her iki operatörün kullanımına bir örnek verilmiştir.</p><h3>scan Operatörü</h3><p><em>scan</em>, akış sırasında gelen her değeri toplayarak devam eder. Yani bir <em>birikim</em> yaratıyor ve bu birikime her bir değer ekleniyor.</p><p>Dizideki her öğenin önceki değerlerin toplamına eklendiğini gösteren aşağıdaki örnekte görebiliriz.</p><pre>import express from &quot;express&quot;;<br>import axios from &quot;axios&quot;;<br>import { from, Subject } from &quot;rxjs&quot;;<br>import { scan, map } from &quot;rxjs/operators&quot;;<br><br>const opScan = express.Router();<br><br>opScan.route(&quot;/opscan&quot;).get(async (req, res, next) =&gt; {<br>  const array = from([10, 20, 30, 40, 50, 60]);<br><br>  array<br>    .pipe(<br>      map((val) =&gt; {<br>        return val;<br>      }),<br>      scan((total, n) =&gt; {<br>        return total + n;<br>      }),<br>      map((sum, index) =&gt; sum)<br>    )<br>    .subscribe(console.log);<br> <br>});<br><br>module.exports = opScan;</pre><p>Çıktı:</p><pre>10 <br>30 <br>60 <br>100 <br>150 <br>210</pre><h3>switchMap Operatörü</h3><p>switchMap’in özelliği onu <em>birleştirmeMap</em> ve <em>concatMap’ten ayırır</em> ; veriler <em>switchMap</em> tarafından yayınlandığında , önceki yayın iptal edilir ve yeni sonuç abone olunur.</p><p>Aşağıdaki örnek, map ve <em>switchMap’i</em> karşılaştırır . Harita operatörü, gözlemlenebilir olarak değer yayar <em>. </em>MergeMap bir iç gözlemlenebilir oluşturur, <em>ona</em> abone olur ve gözlemlenebilir olarak değerini yayar.</p><pre>import express from &quot;express&quot;;<br>import { of } from &quot;rxjs&quot;;<br>import { map, switchMap } from &quot;rxjs/operators&quot;;<br><br>const opswitchmap = express.Router();<br><br>opswitchmap.route(&quot;/opswitchmap&quot;).get(async (res, req, next) =&gt; {<br>  let obs = of(1, 2, 3, 4);<br><br>  //Using MAP<br>  obs<br>    .pipe(<br>      map((val) =&gt; {<br>        return val * 2; //Returning Value<br>      })<br>    )<br>    .subscribe((ret) =&gt; {<br>      console.log(&quot;Recd from map : &quot; + ret);<br>    });<br><br>  // Using SWITCHMAP<br>  obs<br>    .pipe(<br>      switchMap((val) =&gt; {<br>        return of(val * 2); //Returning Value<br>      })<br>    )<br>    .subscribe((ret) =&gt; {<br>      console.log(&quot;Recd from map : &quot; + ret);<br>    });<br>});<br><br>module.exports = opswitchmap;</pre><p>Harita , değeri olarak döndürürken , <em>MergeMap</em> işlevi kullanarak değeri gözlemlenebilir olarak <em>döndürür</em> . Ayrıca yeni oluşturulan gözlemlenebilire abone olur ve değerini akışa yayar.(val*2)(of(val*2))<a href="https://www.tektutorialshub.com/angular/rxjs-observable-using-create-of-from-in-angular/">of</a></p><p>Aşağıdaki örnekte <em>switchMap’in</em> bir öncekini iptal ettiğini ve yeni bir giriş geldiğinde yeniden başladığını görüyoruz. Farkı görmek için örnekte <em>switchMap</em> yerine <em>concatMap</em> ve <em>mergeMap’i</em> deneyebilirsiniz .</p><h3>tap Operatörü</h3><p><em>Tap</em> operatörü ile <em>loglama</em> gibi çıktıyı etkilemeyecek işlemleri gerçekleştirebilirsiniz .</p><pre>import express from &quot;express&quot;;<br>import { of } from &quot;rxjs&quot;;<br>import { tap, map } from &quot;rxjs/operators&quot;;<br><br>const optap = express.Router();<br><br>optap.route(&quot;/optap&quot;).get(async (req, res, next) =&gt; {<br>  const source = of(1, 2, 3, 4, 5)<br>    .pipe(<br>      tap((val) =&gt; console.log(`map&#39;ten önce: ${val}`)),<br>      map((val) =&gt; val + 10),<br>      tap((val) =&gt; console.log(`map&#39;ten sonra: ${val}`))<br>    )<br>    .subscribe((val) =&gt; console.log(val));<br>});<br><br>module.exports = optap;</pre><h3>throwError Operatörü</h3><p>Akış sırasında bir hata oluşursa hatayı ve hata hakkında bir mesajı yazdırabileceğiniz bir operatördür.</p><pre>import express from &quot;express&quot;;<br>import { throwError, of } from &quot;rxjs&quot;;<br>import { concatMap } from &quot;rxjs/operators&quot;;<br><br>const opthrowerror = express.Router();<br><br>opthrowerror.route(&quot;/opthrowerror&quot;).get(async (req, res, next) =&gt; {<br>  const delays$ = of(1000, 2000, 3000, 4000, &quot;5000&quot;);<br><br>  delays$<br>    .pipe(<br>      concatMap((val) =&gt; {<br>        if (typeof val === &quot;number&quot;) {<br>          return of(val);<br>        } else {<br>          // This is probably overkill.<br>          return throwError(() =&gt; new Error(`Invalid number ${val}`));<br>        }<br>      })<br>    ).subscribe({<br>      next: (val) =&gt; console.log(val),<br>      complete: () =&gt; console.log(&quot;Complete!&quot;),<br>      error: (val) =&gt; console.log(`Error: ${val}`),<br>    });<br>});<br><br>module.exports = opthrowerror;</pre><h3>timer Operatörü</h3><p>0 sayısını yaymadan önce belirli bir süre veya kesin tarih için bekleyecek bir gözlemlenebilir oluşturur.</p><pre>import express from &quot;express&quot;;<br>import { timer, of } from &quot;rxjs&quot;;<br>import { concatMapTo } from &quot;rxjs/operators&quot;;<br><br>const optimer = express.Router();<br><br>optimer.route(&quot;/optimer&quot;).get(async (req, res, next) =&gt; {<br>  example - 1;<br>  const source = timer(1000);<br>  //output: 0<br>  const subscribe = source.subscribe((val) =&gt; console.log(&quot;example-1: &quot; + val));<br><br>  //example-2<br>  const source2 = timer(1000, 2000);<br>  //output: 0,1,2,3,4,5......<br>  const subscribe2 = source2.subscribe((val) =&gt;<br>    console.log(&quot;example-2: &quot; + val)<br>  );<br><br>  // example-3<br>  // This could be any observable<br>  const source = of(1, 2, 3);<br><br>  const result = timer(3000)<br>    .pipe(concatMapTo(source))<br>    .subscribe((x) =&gt; console.log(&quot;example-3:&quot; + x));<br>});<br><br>module.exports = optimer;</pre><h3>Sonuç</h3><p>Bu yazıda Rxjs Kütüphanesinden bahsettik. Faydalı olacağını düşünüyorum konunun ucu açık tabii ki çok daha fazla operatör ve konu mevcut. Daha fazla bilgi için:</p><ul><li><a href="https://rxjs-dev.firebaseapp.com/">RxJS</a></li><li><a href="https://rxjs-dev.firebaseapp.com/guide/operators">RxJS</a></li><li><a href="https://rxjs-dev.firebaseapp.com/guide/observable">RxJS</a></li><li><a href="https://rxjs-dev.firebaseapp.com/guide/subject">RxJS</a></li></ul><p>Kaynaklarım:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FtEUda4YzCI4%3Flist%3DPLQVXoXFVVtp1v1_D_8ocGOsWFGvK1Ha-E&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DtEUda4YzCI4&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FtEUda4YzCI4%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/fe228b75b30e6f824ccb35c509740c98/href">https://medium.com/media/fe228b75b30e6f824ccb35c509740c98/href</a></iframe><p><a href="https://ngakademi.com/courses/angular-ile-rxjs-kutuphanesi-egitimi/">Angular İle RxJS Kütüphanesi Eğitimi</a></p><p><a href="https://medium.com/javascript-in-plain-english/everyone-needs-these-rxjs-operators-46cc0dbf4c25#f36e">https://medium.com/javascript-in-plain-english/everyone-needs-these-rxjs-operators-46cc0dbf4c25#f36e</a>Örnek Kodların Adresi :</p><ul><li><a href="https://github.com/azizkale/RxJS---TUTORIAL">https://github.com/azizkale/RxJS---TUTORIAL</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=67742573a1ce" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>