Skip to content

Commit 0f5039e

Browse files
Kuniwakkzaher
authored andcommitted
Use Signals for tapping events instead of Drivers
Driver does not fit to some UI events such as tapping. Because we do not expect to get past "tap" events. But Driver is using `share(replay: 1)`. So it may replay accidentally the past event for some conditions. This replay is useful only for observables like Variables such as `rx.text`, but `rx.tap` is not Variable like. BTW, Signal can fit the usecase. Signal is using `.share()`, so it does not replay past tapping events.
1 parent c141325 commit 0f5039e

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

RxExample/RxExample/Examples/GitHubSignup/UsingDriver/GitHubSignupViewController2.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class GitHubSignupViewController2 : ViewController {
3131
username: usernameOutlet.rx.text.orEmpty.asDriver(),
3232
password: passwordOutlet.rx.text.orEmpty.asDriver(),
3333
repeatedPassword: repeatedPasswordOutlet.rx.text.orEmpty.asDriver(),
34-
loginTaps: signupOutlet.rx.tap.asDriver()
34+
loginTaps: signupOutlet.rx.tap.asSignal()
3535
),
3636
dependency: (
3737
API: GitHubDefaultAPI.sharedAPI,

RxExample/RxExample/Examples/GitHubSignup/UsingDriver/GithubSignupViewModel2.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class GithubSignupViewModel2 {
4545
username: Driver<String>,
4646
password: Driver<String>,
4747
repeatedPassword: Driver<String>,
48-
loginTaps: Driver<Void>
48+
loginTaps: Signal<Void>
4949
),
5050
dependency: (
5151
API: GitHubAPI,

0 commit comments

Comments
 (0)