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
| class PSSAppCompatActivity : AppCompatActivity() { | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| if (areRepositoriesInitialized()) { | |
| setupViewsAndSubscriptions(savedInstanceState) | |
| } else { | |
| runAfterInitializationLogic { setupViewsAndSubscriptions(savedInstanceState) } | |
| } | |
| } |
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
| private val mutableProfile: BehaviorSubject<Profile> = BehaviorSubject.create() | |
| val myProfile: Profile | |
| get() { | |
| if (mutableProfile.hasValue()) { | |
| return mutableProfile.value!! | |
| } else { | |
| throw UninitializedPropertyAccessException("Profile not yet initialized") | |
| } | |
| } |
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
| val completable1 = Completable.error( | |
| Throwable("error 1") | |
| ).subscribeOn(Schedulers.io()) | |
| completable1.subscribe({ | |
| println("success") | |
| }, { | |
| println(it.message) | |
| }) |
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
| val completable1 = Completable.error( | |
| Throwable("error 1") | |
| ).subscribeOn(Schedulers.io()) | |
| completable1.subscribe({ | |
| println("success") | |
| }, { | |
| println(it.message) | |
| }) |
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
| val completable1 = Completable.error( | |
| Throwable("error 1") | |
| ).subscribeOn(Schedulers.io()) | |
| val completable2 = Completable.error( | |
| Throwable("error 2") | |
| ).subscribeOn(Schedulers.io()) | |
| Completable.mergeArray(completable1, completable2).subscribe({ | |
| println("success") |
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
| val completable1 = Completable.error( | |
| Throwable("error 1") | |
| ).subscribeOn(Schedulers.single()) | |
| val completable2 = Completable.error( | |
| Throwable("error 2") | |
| ).subscribeOn(Schedulers.single()) | |
| Completable.mergeArray(completable1, completable2).subscribe({ | |
| println("success") |
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
| fun safeMergeArray(vararg completables: Completable): Completable { | |
| val singles: List<Single<Result>> = completables.map { | |
| it.toSingleDefault<Result>(Result.Complete) | |
| .onErrorReturn { throwable -> | |
| Result.Error(throwable) | |
| } | |
| } | |
| val result = Single.zip(singles) { results: Array<Any> -> | |
| results.firstOrNull { it is Result.Error } ?: Result.Complete |
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
| val completable1 = Completable.error( | |
| Throwable("error 1") | |
| ).subscribeOn(Schedulers.io()) | |
| val completable2 = Completable.error( | |
| Throwable("error 2") | |
| ).subscribeOn(Schedulers.io()) | |
| safeMergeArray(completable1, completable2).subscribe({ | |
| println("success") |
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
| @TestInstance(TestInstance.Lifecycle.PER_METHOD) | |
| @DisplayName("Given we merge two streams") | |
| class SafeMergeArrayTest { | |
| @Nested | |
| @DisplayName("When the first stream throws an error") | |
| inner class FirstStreamError { | |
| @Nested | |
| @DisplayName("When the second stream succeeds") |
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
| @TestInstance(TestInstance.Lifecycle.PER_METHOD) | |
| @DisplayName("Given we merge two streams") | |
| class SafeMergeArrayTest { | |
| @Nested | |
| @DisplayName("When the first stream throws an error") | |
| inner class FirstStreamError { | |
| private val completable1 = Completable.error( | |
| Throwable("error 1") |
OlderNewer