쎄미
쎄미
Sep 7, 2018 · 2 min read

작년에 RxJava 공부하려고 돌아다니다가 이 글을 봤을 땐 이해가 안됐었는데, RxJava를 쓰다보니 이제서야 이해가 되네요 ㅎㅎ

private BehaviorSubject<Long> backPressedSubject = BehaviorSubject.createDefault(0L);...backPressedDisposable = backPressedSubject
.buffer(2, 1)
.map(it -> new Pair<>(it.get(0), it.get(1)))
.map(pair -> pair.second - pair.first < TimeUnit.SECONDS.toMillis(2))
.observeOn(AndroidSchedulers.mainThread())
.subscribe(willFinish -> {
if (willFinish) {
finish();
}
else {
Toast.makeText(getApplicationContext(), "다시 누르면 종료함", Toast.LENGTH_SHORT).show();
}
});

따라서 만들어보니 이렇게도 되던데, 어떤 문제가 발생할 수 있을까요?

    쎄미

    Written by

    쎄미

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade