RxJS 배우기
  • 소개
  • RxJS 배우기
    • 연산자
      • Combination
        • combineAll
        • combineLatest
        • concat
        • concatAll
        • endWith
        • forkJoin
        • merge
        • mergeAll
        • pairwise
        • race
        • startWith
        • withLatestFrom
        • zip
      • Conditional
        • defaultIfEmpty
        • every
        • iif
        • sequenceEqual
      • Creation
        • ajax
        • create
        • defer
        • empty
        • from
        • fromEvent
        • generate
        • interval
        • of
        • range
        • throw
        • timer
      • Error Handling
        • catch / catchError
        • retry
        • retryWhen
      • Multicasting
        • publish
        • multicast
        • share
        • shareReplay
      • Filtering
        • audit
        • auditTime
        • debounce
        • debounceTime
        • distinct
        • distinctUntilChanged
        • distinctUntilKeyChanged
        • filter
        • find
        • first
        • ignoreElements
        • last
        • sample
        • single
        • skip
        • skipUntil
        • skipWhile
        • take
        • takeLast
        • takeUntil
        • takeWhile
        • throttle
        • throttleTime
      • Transformation
        • buffer
        • bufferCount
        • bufferTime
        • bufferToggle
        • bufferWhen
        • concatMap
        • concatMapTo
        • exhaustMap
        • expand
        • groupBy
        • map
        • mapTo
        • mergeMap / flatMap
        • mergeScan
        • partition
        • pluck
        • reduce
        • scan
        • switchMap
        • switchMapTo
        • toArray
        • window
        • windowCount
        • windowTime
        • windowToggle
        • windowWhen
      • Utility
        • tap / do
        • delay
        • delayWhen
        • dematerialize
        • finalize / finally
        • let
        • repeat
        • timeInterval
        • timeout
        • timeoutWith
        • toPromise
      • 전체 목록
    • Subjects
      • AsyncSubject
      • BehaviorSubject
      • ReplaySubject
      • Subject
    • 사용예시
      • Alphabet Invasion Game
      • Battleship Game
      • Breakout Game
      • Car Racing Game
      • Catch The Dot Game
      • Click Ninja Game
      • Flappy Bird Game
      • Game Loop
      • Horizontal Scroll Indicator
      • Http Polling
      • Lockscreen
      • Matrix Digital Rain
      • Memory Game
      • Mine Sweeper Game
      • Platform Jumper Game
      • Progress Bar
      • Save Indicator
      • Smart Counter
      • Space Invaders Game
      • Stop Watch
      • Swipe To Refresh
      • Tank Battle Game
      • Tetris Game
      • Type Ahead
      • Uncover Image Game
    • 개념
      • RxJS 입문서
      • RxJS v5 -> v6 업그레이드
      • 시간 기반의 연산자 비교
      • 연산자 imports의 이해
Powered by GitBook
On this page
  • 제공된 수 만큼, 발생된 값을 건너뜁니다
  • 왜 skip 을 사용할까요?
  • 예시
  • 추가 자료

Was this helpful?

  1. RxJS 배우기
  2. 연산자
  3. Filtering

skip

PrevioussingleNextskipUntil

Last updated 5 years ago

Was this helpful?

signature: skip(the: Number): Observable

제공된 수 만큼, 발생된 값을 건너뜁니다

왜 skip 을 사용할까요?

Skip은 소스로부터 발생된 값들 중 순서대로 x개 만큼을 무시할 수 있게 해줍니다. skip 은 보통, subscription에 여러분이 항상 무시하고자하는 특정 값을 발생시키는 옵저버블이 있을때 사용됩니다. 아마 그러한 값들 중 몇몇개는 필요가 없는 값들이거나 Replay 혹은 BehaviorSubject 를 subscribing하고 있을 것입니다. 뒤늦게 발생하는 값들이 중요하다면, skip 을 사용해서 건너뛰세요.

index가 있는 를 사용해서 skip 의 동작을 만들어낼 수도 있습니다. 예시: .filter((val, index) => index > 1)

예시

예시 1: 발생 전에 값 건너뛰기

( | | )

// RxJS v6+
import { interval } from 'rxjs';
import { skip } from 'rxjs/operators';

//매 1초마다 값 발생
const source = interval(1000);
//첫 5개의 발생된 값 건너뛰기
const example = source.pipe(skip(5));
//결과: 5...6...7...8........
const subscribe = example.subscribe(val => console.log(val));

예시2: 특정 filter 사용사례에 대한 짧은 설명

// RxJS v6+
import { from } from 'rxjs';
import { skip, filter } from 'rxjs/operators';

const numArrayObs = from([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);

// 3,4,5...
const skipObs = numArrayObs.pipe(skip(2)).subscribe(console.log);

// 3,4,5...
const filterObs = numArrayObs
  .pipe(filter((val, index) => index > 1))
  .subscribe(console.log);

//같은 결과군요!

추가 자료

( | | )

- 공식 문서

- André Staltz

소스 코드:

filter
StackBlitz
jsBin
jsFiddle
StackBlitz
jsBin
jsFiddle
📰
skip
📹
💵
Filtering 연산자: take, first, skip
📂
https://github.com/ReactiveX/rxjs/blob/master/src/internal/operators/skip.ts