{"id":33151,"date":"2025-10-30T08:42:06","date_gmt":"2025-10-30T05:42:06","guid":{"rendered":"https:\/\/fatihsoysal.com\/blog\/?p=33151"},"modified":"2025-10-30T08:42:06","modified_gmt":"2025-10-30T05:42:06","slug":"angular-cdk-ile-breakpointleri-tespit-etme-kapsamli-bir-rehber","status":"publish","type":"post","link":"https:\/\/fatihsoysal.com\/blog\/angular-cdk-ile-breakpointleri-tespit-etme-kapsamli-bir-rehber\/","title":{"rendered":"Angular CDK ile Breakpointleri Tespit Etme: Kapsaml\u0131 Bir Rehber"},"content":{"rendered":"<p><body><\/p>\n<h2>Angular CDK ile Breakpointleri Tespit Etme: Kapsaml\u0131 Bir Rehber<\/h2>\n<p>Modern web uygulamalar\u0131, masa\u00fcst\u00fc bilgisayarlar, tabletler ve ak\u0131ll\u0131 telefonlar gibi \u00e7ok \u00e7e\u015fitli cihazlarda sorunsuz bir kullan\u0131c\u0131 deneyimi sunmak zorundad\u0131r. Bu, duyarl\u0131 (responsive) tasar\u0131m\u0131n temelini olu\u015fturur. Duyarl\u0131 tasar\u0131m\u0131n kritik bir bile\u015feni, uygulaman\u0131n farkl\u0131 ekran boyutlar\u0131na g\u00f6re davran\u0131\u015f\u0131n\u0131 ve g\u00f6r\u00fcn\u00fcm\u00fcn\u00fc ayarlamas\u0131na olanak tan\u0131yan &#8220;breakpoint&#8221;lerdir. Peki, Angular uygulamalar\u0131n\u0131zda bu breakpoint&#8217;leri dinamik olarak nas\u0131l tespit edebilir ve uygulaman\u0131z\u0131n mant\u0131\u011f\u0131n\u0131 buna g\u00f6re nas\u0131l uyarlayabilirsiniz?<\/p>\n<p>\u0130\u015fte bu noktada Angular Component Dev Kit (CDK) devreye giriyor. Angular CDK, Angular ekibinin geli\u015ftiricilere sundu\u011fu, temel UI davran\u0131\u015flar\u0131 i\u00e7in yeniden kullan\u0131labilir, eri\u015filebilir ve y\u00fcksek performansl\u0131 bile\u015fenler sa\u011flayan g\u00fc\u00e7l\u00fc bir ara\u00e7 setidir. Bu rehberde, Angular CDK&#8217;n\u0131n <code>BreakpointObserver<\/code> servisini kullanarak uygulaman\u0131z\u0131n mevcut ekran boyutunu nas\u0131l alg\u0131layaca\u011f\u0131n\u0131z\u0131 ve bu bilgiye dayanarak dinamik olarak nas\u0131l tepki verece\u011finizi detayl\u0131 bir \u015fekilde inceleyece\u011fiz.<\/p>\n<h3>Angular CDK ve BreakpointObserver&#8217;a Genel Bak\u0131\u015f<\/h3>\n<p>Angular CDK, Material Design spesifikasyonlar\u0131ndan ba\u011f\u0131ms\u0131z olarak Angular uygulamalar\u0131nda yayg\u0131n olarak kullan\u0131lan i\u015flevsellikleri soyutlayan bir dizi ara\u00e7 sa\u011flar. Bu ara\u00e7lar aras\u0131nda eri\u015filebilirlik yard\u0131mc\u0131lar\u0131, s\u00fcr\u00fckle-b\u0131rak i\u015flevselli\u011fi, portal y\u00f6netimi ve layout ara\u00e7lar\u0131 bulunur. Konumuzla ilgili olan <code>@angular\/cdk\/layout<\/code> paketi, uygulaman\u0131z\u0131n ekran boyutuna ve y\u00f6nelimine g\u00f6re d\u00fczenini dinamik olarak ayarlamak i\u00e7in g\u00fc\u00e7l\u00fc mekanizmalar sunar.<\/p>\n<p><code>BreakpointObserver<\/code>, bu paketin kalbinde yer alan bir servistir. Temel olarak, taray\u0131c\u0131n\u0131n yerel medya sorgular\u0131 API&#8217;sini sarmalar ve belirli medya sorgular\u0131n\u0131n (yani breakpoint&#8217;lerin) \u015fu anda e\u015fle\u015fip e\u015fle\u015fmedi\u011fini g\u00f6zlemlemenize olanak tan\u0131r. Bir medya sorgusu e\u015fle\u015fti\u011finde veya e\u015fle\u015fmeyi b\u0131rakt\u0131\u011f\u0131nda, <code>BreakpointObserver<\/code> bir <code>Observable<\/code> arac\u0131l\u0131\u011f\u0131yla g\u00fcncellemeler yay\u0131nlar. Bu sayede, uygulaman\u0131z\u0131n bile\u015fenleri veya servisleri, ekran boyutu de\u011fi\u015fikliklerine an\u0131nda tepki verebilir.<\/p>\n<p><code>BreakpointObserver<\/code>&#8216;\u0131n en b\u00fcy\u00fck avantajlar\u0131ndan biri, CSS medya sorgular\u0131n\u0131n g\u00fcc\u00fcn\u00fc Angular&#8217;\u0131n reaktif programlama yetenekleriyle birle\u015ftirmesidir. Bu, sadece stil de\u011fi\u015fikliklerinin \u00f6tesine ge\u00e7erek, uygulaman\u0131z\u0131n i\u015f mant\u0131\u011f\u0131n\u0131, bile\u015fen yap\u0131s\u0131n\u0131 veya hatta veri getirme stratejilerini ekran boyutuna g\u00f6re dinamik olarak de\u011fi\u015ftirebilmenizi sa\u011flar. \u00d6rne\u011fin, k\u00fc\u00e7\u00fck ekranlarda farkl\u0131 bir navigasyon men\u00fcs\u00fc g\u00f6stermek, b\u00fcy\u00fck ekranlarda daha fazla s\u00fctunlu bir d\u00fczen kullanmak veya belirli verileri yaln\u0131zca belirli ekran boyutlar\u0131nda y\u00fcklemek gibi senaryolar\u0131 kolayca y\u00f6netebilirsiniz.<\/p>\n<h3>BreakpointObserver Kullan\u0131m\u0131 ve \u00d6rnekleri<\/h3>\n<h4>Angular CDK Kurulumu<\/h4>\n<p><code>BreakpointObserver<\/code>&#8216;\u0131 kullanmaya ba\u015flamadan \u00f6nce, Angular projenize CDK&#8217;y\u0131 eklemeniz gerekir. Bu, a\u015fa\u011f\u0131daki komutla kolayca yap\u0131labilir:<\/p>\n<pre><code class=\"language-bash\">ng add @angular\/cdk<\/code><\/pre>\n<p>Bu komut, CDK&#8217;y\u0131 projenize ekleyecek ve gerekli ba\u011f\u0131ml\u0131l\u0131klar\u0131 y\u00fckleyecektir.<\/p>\n<h4>Temel Kullan\u0131m<\/h4>\n<p><code>BreakpointObserver<\/code>&#8216;\u0131 bir bile\u015fen i\u00e7inde kullanmak i\u00e7in \u00f6ncelikle onu enjekte etmeniz ve ard\u0131ndan <code>observe()<\/code> metodunu \u00e7a\u011f\u0131rman\u0131z gerekir. <code>observe()<\/code> metodu, izlemek istedi\u011finiz medya sorgular\u0131n\u0131 (string veya string dizisi olarak) al\u0131r ve bir <code>Observable<BreakpointState><\/code> d\u00f6nd\u00fcr\u00fcr. <code>BreakpointState<\/code> nesnesi, hangi medya sorgular\u0131n\u0131n e\u015fle\u015fti\u011fini ve genel olarak bir e\u015fle\u015fme olup olmad\u0131\u011f\u0131n\u0131 bildiren bilgiler i\u00e7erir.<\/p>\n<p>Angular CDK, yayg\u0131n cihaz boyutlar\u0131 i\u00e7in \u00f6nceden tan\u0131mlanm\u0131\u015f breakpoint&#8217;ler sunar. Bunlara <code>Breakpoints<\/code> enum&#8217;u arac\u0131l\u0131\u011f\u0131yla eri\u015febilirsiniz (\u00f6rne\u011fin, <code>Breakpoints.Handset<\/code>, <code>Breakpoints.Tablet<\/code>, <code>Breakpoints.Web<\/code>).<\/p>\n<p>A\u015fa\u011f\u0131daki \u00f6rnekte, bir bile\u015fenin mobil (Handset) mi yoksa daha b\u00fcy\u00fck bir ekran (Web) mi oldu\u011funu nas\u0131l tespit etti\u011fini g\u00f6rebilirsiniz:<\/p>\n<pre><code class=\"language-typescript\">import { Component, OnInit, OnDestroy } from '@angular\/core';\nimport { BreakpointObserver, Breakpoints, BreakpointState } from '@angular\/cdk\/layout';\nimport { Observable, Subject } from 'rxjs';\nimport { map, takeUntil } from 'rxjs\/operators';\n\n@Component({\n  selector: 'app-responsive-layout',\n  template: <code>\n    <h3>Breakpoint Tespiti<\/h3>\n    <div *ngIf=\"isHandset$ | async\">\n      <p>\u015eu anda mobil (handset) boyutundas\u0131n\u0131z.<\/p>\n      <button>Mobil Men\u00fc<\/button>\n    <\/div>\n    <div *ngIf=\"(isHandset$ | async) === false\">\n      <p>\u015eu anda daha b\u00fcy\u00fck bir ekran boyutundas\u0131n\u0131z.<\/p>\n      <button>Masa\u00fcst\u00fc Men\u00fc<\/button>\n    <\/div>\n\n    <h4>Mevcut E\u015fle\u015fen Breakpointler:<\/h4>\n    <ul>\n      <li *ngFor=\"let bp of matchedBreakpoints\">{{ bp }}<\/li>\n    <\/ul>\n  <\/code>,\n  styles: [<code>\n    div { padding: 10px; border: 1px solid #ccc; margin-bottom: 10px; }\n    button { padding: 8px 15px; background-color: #007bff; color: white; border: none; cursor: pointer; border-radius: 4px; }\n    button:hover { background-color: #0056b3; }\n  <\/code>]\n})\nexport class ResponsiveLayoutComponent implements OnInit, OnDestroy {\n  isHandset$: Observable<boolean>;\n  matchedBreakpoints: string[] = [];\n  private destroy$ = new Subject<void>();\n\n  constructor(private breakpointObserver: BreakpointObserver) {\n    this.isHandset$ = this.breakpointObserver.observe(Breakpoints.Handset)\n      .pipe(\n        map(result => result.matches)\n      );\n  }\n\n  ngOnInit(): void {\n    this.breakpointObserver.observe([\n      Breakpoints.Handset,\n      Breakpoints.Tablet,\n      Breakpoints.WebLandscape,\n      Breakpoints.WebPortrait,\n      '(min-width: 1200px)' \/\/ \u00d6zel bir breakpoint\n    ]).pipe(\n      takeUntil(this.destroy$)\n    ).subscribe((state: BreakpointState) => {\n      this.matchedBreakpoints = [];\n      for (const query of Object.keys(state.breakpoints)) {\n        if (state.breakpoints[query]) {\n          this.matchedBreakpoints.push(query);\n        }\n      }\n      console.log('Breakpoint State:', state);\n    });\n  }\n\n  ngOnDestroy(): void {\n    this.destroy$.next();\n    this.destroy$.complete();\n  }\n}<\/code><\/pre>\n<p>Bu \u00f6rnekte:<\/p>\n<ul>\n<li><code>BreakpointObserver<\/code> servisi enjekte edilir.<\/li>\n<li><code>Breakpoints.Handset<\/code> medya sorgusunu izleyen bir <code>Observable<\/code> olu\u015fturulur. <code>map(result => result.matches)<\/code> ile sadece e\u015fle\u015fme durumunu (<code>true<\/code>\/<code>false<\/code>) d\u00f6nd\u00fcr\u00fcr\u00fcz.<\/li>\n<li>HTML \u015fablonunda <code>async<\/code> pipe kullanarak <code>isHandset$<\/code> Observable&#8217;\u0131n\u0131 do\u011frudan kullan\u0131r\u0131z. Bu, Angular&#8217;\u0131n otomatik olarak abone olup aboneli\u011fi kald\u0131rmas\u0131n\u0131 sa\u011flar.<\/li>\n<li>\u0130kinci <code>observe<\/code> \u00e7a\u011fr\u0131s\u0131, birden fazla \u00f6n tan\u0131ml\u0131 ve \u00f6zel breakpoint&#8217;i ayn\u0131 anda nas\u0131l izleyece\u011fimizi g\u00f6sterir. <code>BreakpointState<\/code> nesnesinden hangi sorgular\u0131n e\u015fle\u015fti\u011fini bulabiliriz.<\/li>\n<li><code>takeUntil(this.destroy$)<\/code> ve <code>ngOnDestroy<\/code> i\u00e7inde <code>destroy$.next()<\/code> ile bellekte s\u0131z\u0131nt\u0131 olmamas\u0131 i\u00e7in Observable aboneli\u011finin temizlendi\u011finden emin oluruz.<\/li>\n<\/ul>\n<h4>\u00d6zel Breakpointler Tan\u0131mlama<\/h4>\n<p><code>Breakpoints<\/code> enum&#8217;u kullan\u0131\u015fl\u0131 olsa da, bazen uygulaman\u0131z\u0131n \u00f6zel ihtiya\u00e7lar\u0131na g\u00f6re kendi medya sorgular\u0131n\u0131z\u0131 tan\u0131mlaman\u0131z gerekebilir. <code>observe()<\/code> metoduna do\u011frudan CSS medya sorgusu string&#8217;leri ge\u00e7irebilirsiniz:<\/p>\n<pre><code class=\"language-typescript\">this.breakpointObserver.observe([\n  '(min-width: 768px) and (max-width: 1024px)', \/\/ Tablet boyutlar\u0131 i\u00e7in\n  '(orientation: portrait)', \/\/ Dikey y\u00f6nelim i\u00e7in\n  'screen and (min-resolution: 2dppx)' \/\/ Y\u00fcksek \u00e7\u00f6z\u00fcn\u00fcrl\u00fckl\u00fc ekranlar i\u00e7in\n]).subscribe(result => {\n  if (result.matches) {\n    console.log('\u00d6zel breakpoint e\u015fle\u015fti:', result.breakpoints);\n  }\n});<\/code><\/pre>\n<p>Bu esneklik, uygulaman\u0131z\u0131n tasar\u0131m\u0131n\u0131 ve davran\u0131\u015f\u0131n\u0131 en ince ayr\u0131nt\u0131s\u0131na kadar kontrol etmenizi sa\u011flar.<\/p>\n<h3>Pratik Uygulama Senaryolar\u0131 ve \u0130pu\u00e7lar\u0131<\/h3>\n<h4>Servis Olarak Kullan\u0131m<\/h4>\n<p>Breakpoint alg\u0131lama mant\u0131\u011f\u0131n\u0131 merkezi bir serviste tutmak, uygulaman\u0131z\u0131n \u00f6l\u00e7eklenebilirli\u011fi ve bak\u0131m\u0131 a\u00e7\u0131s\u0131ndan en iyi yakla\u015f\u0131md\u0131r. Bu, farkl\u0131 bile\u015fenlerin ayn\u0131 breakpoint durumuna abone olmas\u0131n\u0131 ve tutarl\u0131 bir \u015fekilde tepki vermesini sa\u011flar.<\/p>\n<pre><code class=\"language-typescript\">\/\/ breakpoint.service.ts\nimport { Injectable } from '@angular\/core';\nimport { BreakpointObserver, Breakpoints, BreakpointState } from '@angular\/cdk\/layout';\nimport { Observable } from 'rxjs';\nimport { map, shareReplay } from 'rxjs\/operators';\n\n@Injectable({\n  providedIn: 'root'\n})\nexport class BreakpointService {\n  isHandset$: Observable<boolean>;\n  isTablet$: Observable<boolean>;\n  isWeb$: Observable<boolean>;\n  currentBreakpoint$: Observable<string>;\n\n  constructor(private breakpointObserver: BreakpointObserver) {\n    this.isHandset$ = this.breakpointObserver.observe(Breakpoints.Handset)\n      .pipe(\n        map(result => result.matches),\n        shareReplay() \/\/ \u00c7oklu abonelikler i\u00e7in tek bir yay\u0131n sa\u011flar\n      );\n\n    this.isTablet$ = this.breakpointObserver.observe(Breakpoints.Tablet)\n      .pipe(\n        map(result => result.matches),\n        shareReplay()\n      );\n\n    this.isWeb$ = this.breakpointObserver.observe(Breakpoints.Web)\n      .pipe(\n        map(result => result.matches),\n        shareReplay()\n      );\n    \n    \/\/ Hangi breakpoint'in aktif oldu\u011funu g\u00f6steren bir Observable\n    this.currentBreakpoint$ = this.breakpointObserver.observe([\n      Breakpoints.Handset,\n      Breakpoints.Tablet,\n      Breakpoints.Web\n    ]).pipe(\n      map((result: BreakpointState) => {\n        if (result.breakpoints[Breakpoints.Handset]) {\n          return 'Handset';\n        }\n        if (result.breakpoints[Breakpoints.Tablet]) {\n          return 'Tablet';\n        }\n        if (result.breakpoints[Breakpoints.Web]) {\n          return 'Web';\n        }\n        return 'Unknown';\n      }),\n      shareReplay()\n    );\n  }\n}<\/code><\/pre>\n<p>Art\u0131k herhangi bir bile\u015fen bu servisi enjekte ederek g\u00fcncel breakpoint durumuna kolayca eri\u015febilir:<\/p>\n<pre><code class=\"language-typescript\">\/\/ app.component.ts\nimport { Component } from '@angular\/core';\nimport { BreakpointService } from '.\/breakpoint.service';\n\n@Component({\n  selector: 'app-root',\n  template: <code>\n    <h2>Uygulama Genelinde Breakpoint Tespiti<\/h2>\n    <div *ngIf=\"breakpointService.isHandset$ | async\">\n      <p>Mobil cihazda g\u00f6r\u00fcnt\u00fcleniyor.<\/p>\n    <\/div>\n    <div *ngIf=\"breakpointService.isTablet$ | async\">\n      <p>Tablette g\u00f6r\u00fcnt\u00fcleniyor.<\/p>\n    <\/div>\n    <div *ngIf=\"breakpointService.isWeb$ | async\">\n      <p>Masa\u00fcst\u00fc\/Web cihaz\u0131nda g\u00f6r\u00fcnt\u00fcleniyor.<\/p>\n    <\/div>\n    <p>Mevcut Breakpoint: {{ breakpointService.currentBreakpoint$ | async }}<\/p>\n  <\/code>\n})\nexport class AppComponent {\n  constructor(public breakpointService: BreakpointService) {}\n}<\/code><\/pre>\n<h4>Performans \u0130pu\u00e7lar\u0131<\/h4>\n<ul>\n<li><strong><code>shareReplay()<\/code> Kullan\u0131m\u0131:<\/strong> Bir serviste <code>BreakpointObserver<\/code> kullan\u0131rken, <code>shareReplay()<\/code> operat\u00f6r\u00fcn\u00fc kullanmak \u00f6nemlidir. Bu, birden fazla abonenin ayn\u0131 Observable&#8217;a abone olmas\u0131 durumunda, her abonenin medya sorgusunu tekrar tekrar \u00e7al\u0131\u015ft\u0131rmak yerine, tek bir medya sorgusu aboneli\u011fini payla\u015fmas\u0131n\u0131 sa\u011flar. Bu, performans\u0131 art\u0131r\u0131r.<\/li>\n<li><strong><code>async<\/code> Pipe:<\/strong> Bile\u015fen \u015fablonlar\u0131nda <code>async<\/code> pipe kullanmak, bellek s\u0131z\u0131nt\u0131lar\u0131n\u0131 \u00f6nlemenin en iyi yoludur, \u00e7\u00fcnk\u00fc Angular Observable&#8217;a otomatik olarak abone olur ve bile\u015fen yok edildi\u011finde aboneli\u011fi kald\u0131r\u0131r.<\/li>\n<li><strong><code>distinctUntilChanged()<\/code>:<\/strong> E\u011fer bir Observable&#8217;dan gelen de\u011ferlerin yaln\u0131zca de\u011fi\u015fti\u011finde emit yapmas\u0131n\u0131 istiyorsan\u0131z, <code>distinctUntilChanged()<\/code> operat\u00f6r\u00fcn\u00fc kullanabilirsiniz. <code>BreakpointObserver<\/code> zaten dahili olarak optimize edilmi\u015ftir, ancak karma\u015f\u0131k d\u00f6n\u00fc\u015f\u00fcmler yap\u0131yorsan\u0131z faydal\u0131 olabilir.<\/li>\n<\/ul>\n<h4>Kullan\u0131c\u0131 Deneyimi \u0130yile\u015ftirmeleri<\/h4>\n<ul>\n<li><strong>Navigasyon De\u011fi\u015fiklikleri:<\/strong> K\u00fc\u00e7\u00fck ekranlarda bir hamburger men\u00fcs\u00fc, b\u00fcy\u00fck ekranlarda ise tam bir navigasyon \u00e7ubu\u011fu g\u00f6r\u00fcnt\u00fclemek.<\/li>\n<li><strong>Veri Yo\u011funlu\u011fu:<\/strong> K\u00fc\u00e7\u00fck ekranlarda daha az bilgi g\u00f6stererek veya kartlar\u0131n d\u00fczenini de\u011fi\u015ftirerek daha okunakl\u0131 bir deneyim sunmak. \u00d6rne\u011fin, b\u00fcy\u00fck ekranlarda 3 s\u00fctunlu bir kart d\u00fczeni, mobil cihazlarda tek s\u00fctunlu bir d\u00fczen.<\/li>\n<li><strong>Bile\u015fen Y\u00fckleme:<\/strong> Yaln\u0131zca belirli ekran boyutlar\u0131nda ihtiya\u00e7 duyulan a\u011f\u0131r bile\u015fenleri veya mod\u00fclleri tembelce (lazy-load) y\u00fcklemek.<\/li>\n<\/ul>\n<h4>Test Edilebilirlik<\/h4>\n<p><code>BreakpointObserver<\/code>&#8216;\u0131 test etmek genellikle bir <code>Spy<\/code> nesnesi olu\u015fturarak veya bir mock servisi sa\u011flayarak yap\u0131l\u0131r. <code>TestBed<\/code>&#8216;i kullanarak <code>BreakpointObserver<\/code>&#8216;\u0131 mock&#8217;layabilir ve <code>observe<\/code> metodunun belirli bir <code>Observable<\/code>&#8216;\u0131 d\u00f6nd\u00fcrmesini sa\u011flayabilirsiniz.<\/p>\n<pre><code class=\"language-typescript\">\/\/ BreakpointObserver'\u0131 mock'lama \u00f6rne\u011fi\nimport { TestBed } from '@angular\/core\/testing';\nimport { BreakpointObserver, Breakpoints } from '@angular\/cdk\/layout';\nimport { of } from 'rxjs';\nimport { ResponsiveLayoutComponent } from '.\/responsive-layout.component';\n\ndescribe('ResponsiveLayoutComponent', () => {\n  let component: ResponsiveLayoutComponent;\n  let breakpointObserverSpy: jasmine.SpyObj<BreakpointObserver>;\n\n  beforeEach(async () => {\n    breakpointObserverSpy = jasmine.createSpyObj('BreakpointObserver', ['observe']);\n    breakpointObserverSpy.observe.and.returnValue(of({ matches: false, breakpoints: {} })); \/\/ Varsay\u0131lan d\u00f6n\u00fc\u015f de\u011feri\n\n    await TestBed.configureTestingModule({\n      declarations: [ ResponsiveLayoutComponent ],\n      providers: [\n        { provide: BreakpointObserver, useValue: breakpointObserverSpy }\n      ]\n    })\n    .compileComponents();\n  });\n\n  beforeEach(() => {\n    const fixture = TestBed.createComponent(ResponsiveLayoutComponent);\n    component = fixture.componentInstance;\n    fixture.detectChanges();\n  });\n\n  it('should be created', () => {\n    expect(component).toBeTruthy();\n  });\n\n  it('should show handset content when breakpoint matches', async () => {\n    \/\/ Handset breakpoint'inin e\u015fle\u015fti\u011fini sim\u00fcle et\n    breakpointObserverSpy.observe.and.returnValue(of({\n      matches: true,\n      breakpoints: { [Breakpoints.Handset]: true }\n    }));\n    component.ngOnInit(); \/\/ Observable'\u0131 tekrar tetikle\n    component.isHandset$.subscribe(isHandset => {\n      expect(isHandset).toBeTrue();\n    });\n  });\n\n  \/\/ Di\u011fer test senaryolar\u0131...\n});<\/code><\/pre>\n<p>Bu \u015fekilde, bile\u015fenlerinizin ve servislerinizin farkl\u0131 ekran boyutlar\u0131na nas\u0131l tepki verdi\u011fini izole bir \u015fekilde test edebilirsiniz.<\/p>\n<h3>Sonu\u00e7 ve S\u0131k\u00e7a Sorulan Sorular (SSS)<\/h3>\n<p>Angular CDK&#8217;n\u0131n <code>BreakpointObserver<\/code> servisi, modern ve duyarl\u0131 web uygulamalar\u0131 geli\u015ftirmek i\u00e7in vazge\u00e7ilmez bir ara\u00e7t\u0131r. CSS medya sorgular\u0131n\u0131n g\u00fcc\u00fcn\u00fc Angular&#8217;\u0131n reaktif programlama paradigmas\u0131yla birle\u015ftirerek, uygulaman\u0131z\u0131n UI&#8217;s\u0131n\u0131, i\u015f mant\u0131\u011f\u0131n\u0131 ve kullan\u0131c\u0131 deneyimini farkl\u0131 ekran boyutlar\u0131na g\u00f6re dinamik olarak uyarlaman\u0131za olanak tan\u0131r. Merkezi bir servis arac\u0131l\u0131\u011f\u0131yla kullan\u0131ld\u0131\u011f\u0131nda, kodunuz daha temiz, daha s\u00fcrd\u00fcr\u00fclebilir ve daha \u00f6l\u00e7eklenebilir hale gelir.<\/p>\n<p>Uygulaman\u0131z\u0131n her cihazda harika g\u00f6r\u00fcnmesini ve hissettirmesini sa\u011flamak i\u00e7in <code>BreakpointObserver<\/code>&#8216;\u0131 stratejik olarak kullanmak, kullan\u0131c\u0131 memnuniyetini art\u0131racak ve geli\u015ftirme s\u00fcrecinizi kolayla\u015ft\u0131racakt\u0131r.<\/p>\n<h4>S\u0131k\u00e7a Sorulan Sorular (SSS)<\/h4>\n<dl>\n<dt><code>BreakpointObserver<\/code> sadece CSS medya sorgular\u0131n\u0131 m\u0131 kullan\u0131r?<\/dt>\n<dd>Evet, <code>BreakpointObserver<\/code> temel olarak taray\u0131c\u0131n\u0131n yerel <code>window.matchMedia<\/code> API&#8217;sini kullan\u0131r. Bu API, CSS medya sorgular\u0131yla ayn\u0131 s\u00f6zdizimini ve kurallar\u0131 takip eder.<\/dd>\n<dt>Performans \u00fczerinde bir etkisi var m\u0131?<\/dt>\n<dd><code>BreakpointObserver<\/code>, performans\u0131 g\u00f6z \u00f6n\u00fcnde bulundurularak optimize edilmi\u015ftir. Medya sorgular\u0131n\u0131 verimli bir \u015fekilde dinler ve yaln\u0131zca durum de\u011fi\u015fti\u011finde Observable&#8217;a yeni de\u011ferler g\u00f6nderir. <code>shareReplay()<\/code> gibi operat\u00f6rlerin do\u011fru kullan\u0131m\u0131yla performans etkisi minimaldir.<\/dd>\n<dt>Angular Material ile birlikte mi kullanmal\u0131y\u0131m?<\/dt>\n<dd>Hay\u0131r, <code>BreakpointObserver<\/code> Angular Material&#8217;dan ba\u011f\u0131ms\u0131zd\u0131r ve herhangi bir Angular projesinde kullan\u0131labilir. Asl\u0131nda, Angular Material&#8217;\u0131n kendi bile\u015fenleri (\u00f6rne\u011fin, side-nav) i\u00e7 duyarl\u0131 davran\u0131\u015flar\u0131 i\u00e7in <code>BreakpointObserver<\/code>&#8216;\u0131 kullan\u0131r.<\/dd>\n<dt>Birden fazla breakpoint&#8217;i ayn\u0131 anda nas\u0131l izlerim?<\/dt>\n<dd><code>observe()<\/code> metoduna bir string dizisi olarak birden fazla medya sorgusu ge\u00e7irebilirsiniz (\u00f6rne\u011fin, <code>this.breakpointObserver.observe([Breakpoints.Handset, Breakpoints.Tablet])<\/code>). D\u00f6nd\u00fcr\u00fclen <code>BreakpointState<\/code> nesnesi, hangi sorgular\u0131n e\u015fle\u015fti\u011fini <code>breakpoints<\/code> \u00f6zelli\u011fi arac\u0131l\u0131\u011f\u0131yla g\u00f6sterecektir.<\/dd>\n<dt><code>async<\/code> pipe kullanman\u0131n avantaj\u0131 nedir?<\/dt>\n<dd><code>async<\/code> pipe, Observable&#8217;lara otomatik olarak abone olur ve bile\u015fen yok edildi\u011finde aboneli\u011fi otomatik olarak kald\u0131r\u0131r. Bu, bellek s\u0131z\u0131nt\u0131lar\u0131n\u0131 \u00f6nler ve manuel abonelik y\u00f6netimine (<code>.subscribe()<\/code> ve <code>.unsubscribe()<\/code>) g\u00f6re daha temiz ve az hataya a\u00e7\u0131k kod yazman\u0131z\u0131 sa\u011flar.<\/dd>\n<\/dl>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"Angular CDK ile Breakpointleri Tespit Etme: Kapsaml\u0131 Bir Rehber\n  Modern web uygulamalar\u0131, masa\u00fcst\u00fc bilgisayarlar, tabletler ve ak\u0131ll\u0131 tele","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"csco_page_header_type":"","csco_page_load_nextpost":"","csco_page_subscribe_form":"","csco_page_contact_form":"","footnotes":""},"categories":[1488],"tags":[],"class_list":{"0":"post-33151","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-angular","7":"cs-entry","8":"cs-video-wrap"},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v20.5 (Yoast SEO v25.3.1) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Angular CDK ile Breakpointleri Tespit Etme: Kapsaml\u0131 Bir Rehber - Kodlar\u0131n Gizemli D\u00fcnyas\u0131<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/fatihsoysal.com\/blog\/angular-cdk-ile-breakpointleri-tespit-etme-kapsamli-bir-rehber\/\" \/>\n<meta property=\"og:locale\" content=\"tr_TR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Angular CDK ile Breakpointleri Tespit Etme: Kapsaml\u0131 Bir Rehber\" \/>\n<meta property=\"og:description\" content=\"Angular CDK ile Breakpointleri Tespit Etme: Kapsaml\u0131 Bir Rehber  Modern web uygulamalar\u0131, masa\u00fcst\u00fc bilgisayarlar, tabletler ve ak\u0131ll\u0131 tele\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fatihsoysal.com\/blog\/angular-cdk-ile-breakpointleri-tespit-etme-kapsamli-bir-rehber\/\" \/>\n<meta property=\"og:site_name\" content=\"Kodlar\u0131n Gizemli D\u00fcnyas\u0131\" \/>\n<meta property=\"article:published_time\" content=\"2025-10-30T05:42:06+00:00\" \/>\n<meta name=\"author\" content=\"Fatih Soysal\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Yazan:\" \/>\n\t<meta name=\"twitter:data1\" content=\"Fatih Soysal\" \/>\n\t<meta name=\"twitter:label2\" content=\"Tahmini okuma s\u00fcresi\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 dakika\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/angular-cdk-ile-breakpointleri-tespit-etme-kapsamli-bir-rehber\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/angular-cdk-ile-breakpointleri-tespit-etme-kapsamli-bir-rehber\/\"},\"author\":{\"name\":\"Fatih Soysal\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\"},\"headline\":\"Angular CDK ile Breakpointleri Tespit Etme: Kapsaml\u0131 Bir Rehber\",\"datePublished\":\"2025-10-30T05:42:06+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/angular-cdk-ile-breakpointleri-tespit-etme-kapsamli-bir-rehber\/\"},\"wordCount\":1445,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\"},\"articleSection\":[\"Angular\"],\"inLanguage\":\"tr\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/fatihsoysal.com\/blog\/angular-cdk-ile-breakpointleri-tespit-etme-kapsamli-bir-rehber\/#respond\"]}],\"copyrightYear\":\"2025\",\"copyrightHolder\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/angular-cdk-ile-breakpointleri-tespit-etme-kapsamli-bir-rehber\/\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/angular-cdk-ile-breakpointleri-tespit-etme-kapsamli-bir-rehber\/\",\"name\":\"Angular CDK ile Breakpointleri Tespit Etme: Kapsaml\u0131 Bir Rehber - Kodlar\u0131n Gizemli D\u00fcnyas\u0131\",\"isPartOf\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#website\"},\"datePublished\":\"2025-10-30T05:42:06+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/angular-cdk-ile-breakpointleri-tespit-etme-kapsamli-bir-rehber\/#breadcrumb\"},\"inLanguage\":\"tr\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/fatihsoysal.com\/blog\/angular-cdk-ile-breakpointleri-tespit-etme-kapsamli-bir-rehber\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/angular-cdk-ile-breakpointleri-tespit-etme-kapsamli-bir-rehber\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Anasayfa\",\"item\":\"https:\/\/fatihsoysal.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Angular CDK ile Breakpointleri Tespit Etme: Kapsaml\u0131 Bir Rehber\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#website\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/\",\"name\":\"Fatihsoysal.com\",\"description\":\"Blog - Yaz\u0131l\u0131m D\u00fcnyas\u0131 Tecr\u00fcbelerim\",\"publisher\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/fatihsoysal.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"tr\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\",\"name\":\"Fatih Soysal\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"tr\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png\",\"contentUrl\":\"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png\",\"width\":512,\"height\":512,\"caption\":\"Fatih Soysal\"},\"logo\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/\"},\"description\":\"Kullan\u0131m ve kodlama m\u00fckemmeliyetini odak alan uygulamalar olu\u015fturma deneyimine sahip, profesyonel olarak 15+ y\u0131l \u00fczeri deneyime sahip bir yaz\u0131l\u0131m m\u00fchendisi.\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/author\/fatihsoysal\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Angular CDK ile Breakpointleri Tespit Etme: Kapsaml\u0131 Bir Rehber - Kodlar\u0131n Gizemli D\u00fcnyas\u0131","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/fatihsoysal.com\/blog\/angular-cdk-ile-breakpointleri-tespit-etme-kapsamli-bir-rehber\/","og_locale":"tr_TR","og_type":"article","og_title":"Angular CDK ile Breakpointleri Tespit Etme: Kapsaml\u0131 Bir Rehber","og_description":"Angular CDK ile Breakpointleri Tespit Etme: Kapsaml\u0131 Bir Rehber  Modern web uygulamalar\u0131, masa\u00fcst\u00fc bilgisayarlar, tabletler ve ak\u0131ll\u0131 tele","og_url":"https:\/\/fatihsoysal.com\/blog\/angular-cdk-ile-breakpointleri-tespit-etme-kapsamli-bir-rehber\/","og_site_name":"Kodlar\u0131n Gizemli D\u00fcnyas\u0131","article_published_time":"2025-10-30T05:42:06+00:00","author":"Fatih Soysal","twitter_card":"summary_large_image","twitter_misc":{"Yazan:":"Fatih Soysal","Tahmini okuma s\u00fcresi":"10 dakika"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fatihsoysal.com\/blog\/angular-cdk-ile-breakpointleri-tespit-etme-kapsamli-bir-rehber\/#article","isPartOf":{"@id":"https:\/\/fatihsoysal.com\/blog\/angular-cdk-ile-breakpointleri-tespit-etme-kapsamli-bir-rehber\/"},"author":{"name":"Fatih Soysal","@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1"},"headline":"Angular CDK ile Breakpointleri Tespit Etme: Kapsaml\u0131 Bir Rehber","datePublished":"2025-10-30T05:42:06+00:00","mainEntityOfPage":{"@id":"https:\/\/fatihsoysal.com\/blog\/angular-cdk-ile-breakpointleri-tespit-etme-kapsamli-bir-rehber\/"},"wordCount":1445,"commentCount":0,"publisher":{"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1"},"articleSection":["Angular"],"inLanguage":"tr","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fatihsoysal.com\/blog\/angular-cdk-ile-breakpointleri-tespit-etme-kapsamli-bir-rehber\/#respond"]}],"copyrightYear":"2025","copyrightHolder":{"@id":"https:\/\/fatihsoysal.com\/blog\/#organization"}},{"@type":"WebPage","@id":"https:\/\/fatihsoysal.com\/blog\/angular-cdk-ile-breakpointleri-tespit-etme-kapsamli-bir-rehber\/","url":"https:\/\/fatihsoysal.com\/blog\/angular-cdk-ile-breakpointleri-tespit-etme-kapsamli-bir-rehber\/","name":"Angular CDK ile Breakpointleri Tespit Etme: Kapsaml\u0131 Bir Rehber - Kodlar\u0131n Gizemli D\u00fcnyas\u0131","isPartOf":{"@id":"https:\/\/fatihsoysal.com\/blog\/#website"},"datePublished":"2025-10-30T05:42:06+00:00","breadcrumb":{"@id":"https:\/\/fatihsoysal.com\/blog\/angular-cdk-ile-breakpointleri-tespit-etme-kapsamli-bir-rehber\/#breadcrumb"},"inLanguage":"tr","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fatihsoysal.com\/blog\/angular-cdk-ile-breakpointleri-tespit-etme-kapsamli-bir-rehber\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/fatihsoysal.com\/blog\/angular-cdk-ile-breakpointleri-tespit-etme-kapsamli-bir-rehber\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Anasayfa","item":"https:\/\/fatihsoysal.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Angular CDK ile Breakpointleri Tespit Etme: Kapsaml\u0131 Bir Rehber"}]},{"@type":"WebSite","@id":"https:\/\/fatihsoysal.com\/blog\/#website","url":"https:\/\/fatihsoysal.com\/blog\/","name":"Fatihsoysal.com","description":"Blog - Yaz\u0131l\u0131m D\u00fcnyas\u0131 Tecr\u00fcbelerim","publisher":{"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/fatihsoysal.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"tr"},{"@type":["Person","Organization"],"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1","name":"Fatih Soysal","image":{"@type":"ImageObject","inLanguage":"tr","@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png","contentUrl":"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png","width":512,"height":512,"caption":"Fatih Soysal"},"logo":{"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/"},"description":"Kullan\u0131m ve kodlama m\u00fckemmeliyetini odak alan uygulamalar olu\u015fturma deneyimine sahip, profesyonel olarak 15+ y\u0131l \u00fczeri deneyime sahip bir yaz\u0131l\u0131m m\u00fchendisi.","url":"https:\/\/fatihsoysal.com\/blog\/author\/fatihsoysal\/"}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts\/33151","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/comments?post=33151"}],"version-history":[{"count":1,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts\/33151\/revisions"}],"predecessor-version":[{"id":33152,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts\/33151\/revisions\/33152"}],"wp:attachment":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/media?parent=33151"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/categories?post=33151"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/tags?post=33151"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}