-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Fixed issue with NSControl.rx.value multiple observers #1399
Conversation
When multiple observers want to look at NSControl.rx.value, only one would get updates because the returned observable wasn't shared(). This is examplified by the new test added to NSButton This also solves the issue of observers with varying types
Generated by 🚫 Danger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've cherry-picked your commit and created another one because we need to also apply it to develop
branch.
Github probably won't detect the rebase and merge properly.
.takeUntil((control as! NSObject).rx.deallocated) | ||
.share(replay: 1, scope: .forever) | ||
} | ||
.map { [unowned control] _ in getter(control) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be weak.
.takeUntil((control as! NSObject).rx.deallocated) | ||
} | ||
.takeUntil((control as! NSObject).rx.deallocated) | ||
.share(replay: 1, scope: .forever) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this should be .whileConnected.
return observer | ||
} | ||
.takeUntil((control as! NSObject).rx.deallocated) | ||
} | ||
.takeUntil((control as! NSObject).rx.deallocated) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately for some reason still doesn't work with as control.rx.deallocated
, have no idea why.
|
||
XCTAssertEqual(button.state, NSControl.StateValue.on) | ||
XCTAssertEqual(value1, NSControl.StateValue.on) | ||
XCTAssertEqual(value2, NSControl.StateValue.on) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also test replay.
When multiple observers want to look at NSControl.rx.value, only one would get updates because
the returned observable wasn't shared(). This is examplified by the new test added to NSButton
This also solves the issue of observers with varying types
Relates to issue #1398