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
| // Returns the value if the predicate evaluates to `true`; otherwise, returns `nil`. | |
| // this function is similar from kotlin takeIf | |
| // | |
| // let number: Int? = 42 | |
| // let result = number.takeIf { $0 > 40 } // Output: Optional(42) | |
| // let invalidResult = number.takeIf { $0 < 40 } // Output: nil | |
| // | |
| // let string: String? = "some text" | |
| // let resultString = string.takeIf { !$0.isEmpty } // Output: Optional("some text") | |
| // let invalidResultString = resultString.takeIf { $0.isEmpty } // Output: nil |
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
| sealed class Resource<T> ( | |
| val data: T? = null, | |
| val message: String? = null | |
| ) { | |
| class Success<T>(data: T) : Resource<T>(data) | |
| class Loading<T>(data: T? = null) : Resource<T>(data) | |
| class Error<T>(message: String, data: T? = null) : Resource<T>(data, message) | |
| } | |
| class LoginUseCase constructor(private val iUserRepository: IUserRepository) { |
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
| //References: | |
| //https://johnoreilly.dev/posts/kotlinmultiplatform-swift-combine_publisher-flow/ | |
| //https://github.com/Kotlin/kotlinx.coroutines/issues/2306 | |
| //https://stackoverflow.com/questions/64175099/listen-to-kotlin-coroutine-flow-from-ios | |
| //https://mmmnnnmmm.com/kotlin-kmm-swift-ios-stateflow.html | |
| import Foundation | |
| import shared | |
| class Collector<T>: Kotlinx_coroutines_coreFlowCollector { |