Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pairwise broke BehaviorRelay #274

Open
davidfuzju opened this issue Sep 6, 2023 · 0 comments
Open

pairwise broke BehaviorRelay #274

davidfuzju opened this issue Sep 6, 2023 · 0 comments

Comments

@davidfuzju
Copy link

davidfuzju commented Sep 6, 2023

hi, I use pairwise with BehaviorRelay to listener the userInfo's changes, by compared with old and new, then make some animation.

Expected: use pairwise with behaviorRelay, when there is a new subscription, behaviorRelay will emit latest element and with the power of pairwise, subscription will get a old and new tuple
Actual: use pairwise with behaviorRelay, behaviorRelay will stop emit latest element for new subscription

Anyone helps?

// use pairwise
UserDetailManager.shared
.userDetailUpdateRelay
.pairwise()
.subscribe(onNext: { [weak self] (old, new) in 
       // BehaviorRelay not emit latest element for subscription
       // thought I read the doc that pairwise will not emit anything until the source observable emits at least 2 elements
       // however, after behaviorRelay has emit > 2 elements, BehaviorRelay will not emit any element for the new subscription
})
 .disposed(by: rx.disposeBag)

// not use pairwise
UserDetailManager.shared
.userDetailUpdateRelay
.subscribe(onNext: { [weak self] data in 
        // BehaviorRelay will emit latest element for subscription
        // for example, A UIView as a observer to subscribe this relay will get the latest element to show something for user
})
 .disposed(by: rx.disposeBag)

@davidfuzju davidfuzju changed the title pairwise broke behaviorrelay pairwise broke BehaviorRelay Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant