Hi guys, there is a line of code that I could't gu...
# announcements
k
Hi guys, there is a line of code that I could't guess what it is, when ClassA.( ) what will happen?
Copy code
typealias CompletionBlock<T> = UseCase.RequestBlock<T>.() -> Unit
RequestBlock<T> class is like this:
Copy code
class RequestBlock<T> {
    private var onSuccess: ((T) -> Unit)? = null
    private var onFail: ((ErrorModel, CallableImp) -> Unit)? = null
    private var onFinally: (() -> Unit)? = null

    fun onSuccess(block: (T) -> Unit) {
      onSuccess = block
    }

    fun onFail(block: (ErrorModel, CallableImp) -> Unit) {
      onFail = block
    }

    fun onFinally(block: () -> Unit) {
      onFinally = block
    }


    operator fun invoke(result: T) {
      onSuccess?.invoke(result)
    }

    operator fun invoke(error: ErrorModel, apiCallable: CallableImp) {
      onFail?.invoke(error, apiCallable)
    }

    operator fun invoke() {
      onFinally?.invoke()
    }
  }
o