This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final Observable<LoginRequest> lastCredentialsObservable = Observable.combineLatest( | |
emailSubject, | |
passwordSubject, | |
new Func2<String, String, LoginRequest>() { | |
@Override | |
public LoginRequest call(String email, String password) { | |
return new LoginRequest(email, password); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BehaviorSubject<String> emailSubject = BehaviorSubject.create(); | |
BehaviorSubject<String> passwordSubject = BehaviorSubject.create(); | |
PublishSubject<Void> loginClickSubject = PublishSubject.create(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Observable<LoginRequest> loginObservable = lastCredentialsObservable | |
.sample(loginClickSubject); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Observable<LoginRequest> loginObservable = loginClickSubject | |
.flatMap(new Func1<Void, Observable<LoginRequest>>() { | |
@Override | |
public Observable<LoginRequest> call(Void ignore) { | |
return lastCredentialsObservable; | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Observable<LoginRequest> loginObservable = loginClickSubject | |
.withLatestFrom(lastCredentialsObservable, new Func2<Void, LoginRequest, LoginRequest>() { | |
@Override | |
public LoginRequest call(Void ignore, LoginRequest credentials) { | |
return credentials; | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
swagger: "2.0" | |
info: | |
version: 1.0.0 | |
title: Zumba's API | |
description: Documentation about Zumba's API. | |
contact: | |
name: Zumba Engineering Team | |
email: [email protected] | |
url: https://tech.zumba.com | |
host: apiv3.zumba.com |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RxView.clicks(fab) | |
.throttleFirst(1, TimeUnit.SECONDS) // prevents crazy clicks | |
.observeOn(AndroidSchedulers.mainThread()) | |
.switchMap(ignore -> favoritesManager.addOrRemoveFromFavs(postId)) // toggle cache state and make API request | |
.subscribe(responseOrError -> { | |
if (responseOrError.isError()) { | |
Toast.makeText(PostDetailsActivity.this, "API error", Toast.LENGTH_SHORT).show(); | |
} | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RxView.clicks(favButton) | |
.throttleFirst(1, TimeUnit.SECONDS) //Prevents from crazy clicks | |
.switchMap(ignore -> favoritesManager.addOrRemoveFromFavs(postId))//Toggle cache state and make API request | |
.subscribe(responseOrError -> { | |
if (responseOrError.isError()) { | |
Toast.makeText(PostDetailsActivity.this, "API error", Toast.LENGTH_SHORT).show(); | |
} | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void onFavoriteButtonClick() { | |
favoriteButton.setFavorite(!favoriteButton.isFavorite()) // toggle state | |
makeFavRequest(favoriteButton.isFavorite()) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
favsManager.getIsFavoriteObservable(postId) | |
.subscribe(isFavorite -> favButton.setFavorite(isFavorite)); |
OlderNewer