aboutsummaryrefslogtreecommitdiff
path: root/iosApp/iosApp/Shared/FlowCollector.swift
blob: 3fd6c606c859feaef0eff02b142cdb9d4c565f2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//
//  FlowCollector.swift
//  iosApp
//
//  Created by Iván on 23/01/22.
//  Copyright © 2022 orgName. All rights reserved.
//

import Foundation
import shared

class Collector<T>: Kotlinx_coroutines_coreFlowCollector {
    
    let callback: (T) -> Void
    
    init(callback: @escaping (T) -> Void) {
        self.callback = callback
    }
    
    func emit(value: Any?, completionHandler: @escaping (KotlinUnit?, Error?) -> Void) {
        callback(value as! T)
        
        completionHandler(KotlinUnit(), nil)
    }
}