Skip to content

Instantly share code, notes, and snippets.

View AppDelegate.swift
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
var socketChannel: SocketChannel!
override func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
GeneratedPluginRegistrant.register(with: self)
socketChannel = SocketChannel(window)
View RunScript
cd "$SRCROOT/KotlinSharedNetwork-android"
./gradlew :SharedNetwork:packForXCode -PXCODE_CONFIGURATION=${CONFIGURATION} -Pkotlin.device="$KOTLIN_DEVICE"
View build.gradle
targets {
// Read the "kotlin.device" variable passed by Xcode
def isSim = findProperty("kotlin.device") == "iosSim"
// Apply the preset according to the device
def iosPreset = isSim ? presets.iosX64 : presets.iosArm64
fromPreset(iosPreset, 'iOS') {
binaries {
framework('SharedNetwork')
View gist:0834c49e791a3b7269586ca8efbf8058
def rx_swift
pod 'RxSwift', '~> 4.4'
end
target 'RKProfile' do
use_frameworks!
workspace 'REKAB'
project 'RKProfile/RKProfile.xcodeproj'
rx_swift
View StoryboardInitializable.swift
import UIKit
public protocol StoryboardInitializable {
static var storyboardIdentifier: String { get }
}
public extension StoryboardInitializable where Self: UIViewController {
public static var storyboardIdentifier: String {
return String(describing: Self.self)
}
View CustomRxVar.swift
public var rx_startLoading: AnyObserver<Bool> {
return Binder(self, binding: { [weak self] (view, visible) in
self?.showLoaingLayer(show: visible)
}).asObserver()
}
View BehaviorRelayExample.swift
var postList = BehaviorRelay<[Post]?>(value: nil)
postList.bindTo(to: showList).disposed(by: bag)
View BindButton.swift
yourButton.rx.tap.asObservable().bind(to: viewModel.someObserver).disposed(by: bag)
View didSet.swift
var isLoading: Bool = false {
didSet {
showLoading()
}
}
View actual.kt
import kotlin.coroutines.*
import kotlinx.coroutines.*
import platform.darwin.*
internal actual val dispatcher: CoroutineDispatcher = NsQueueDispatcher(dispatch_get_main_queue())
internal class NsQueueDispatcher(private val dispatchQueue: dispatch_queue_t) : CoroutineDispatcher() {
override fun dispatch(context: CoroutineContext, block: Runnable) {
dispatch_async(dispatchQueue) {
block.run()