Skip to content

Instantly share code, notes, and snippets.

__attribute__((objc_subclassing_restricted))
__attribute__((swift_name("PokeApi")))
@interface AppPokeApi : KotlinBase
- (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer));
+ (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead")));
- (void)getPokemonListSuccess:(AppKotlinUnit *(^)(NSArray<AppPokemonEntry *> *))success failure:(AppKotlinUnit *(^)(AppKotlinThrowable * _Nullable))failure __attribute__((swift_name("getPokemonList(success:failure:)")));
@end;
getPokemonList(
success: { data in
self.update(data: data)
return KotlinUnit()
}, failure: {
self.handleError($0?.message)
return KotlinUnit()
})
getPokemonList(
success: { data in
self.update(data: data)
return KotlinUnit()
}, failure: {
self.handleError($0?.message)
return KotlinUnit()
})
class PokeApi {
fun getPokemonList(success: (List<PokemonEntry>) -> Unit, failure: (Throwable?) -> Unit) {
...
}
}
func perform(followAction: FollowAction,
cache: Cache<FanClub>,
updateHandler: @escaping (_ isRevertOnFailure: Bool) -> Void) {
// update cache optimistically
let originalFanClub = cache.value(for: followAction.fanClubId)
if let updatedFanClub = originalFanClub?.updated(with: followAction) {
cache.set(updatedFanClub, for: followAction.fanClubId)
}
updateHandler(false)
lastFollowActionUpdatedAt = Date()
import Foundation
protocol Reversible {
var isOn: Bool { get set }
mutating func reverse()
func reversed() -> Self
}
extension Reversible {
class FeedViewController: BaseViewController {
//...
override func viewDidLoad() {
super.viewDidLoad()
setupViews()
setupBindings()
sessionDidUpdate(appCoordinator.session)
}
import UIKit
import Lottie
protocol LikeSwitchDelegate: class {
func likeSwitch(_ likeSwitch: LikeSwitch, didToggle isSelected: Bool)
}
class LikeSwitch: UIView {
weak var delegate: LikeSwitchDelegate?
import Foundation
import RxSwift
import RxCocoa
class SimplifiedPagedResponseFetcher<LoaderInput, LoaderOutput>
where LoaderInput: Pageable, LoaderOutput: PagedResponse {
/// The main actor here 🤘. Sends all the Elements currently available.
let elementsRelay = BehaviorRelay<[LoaderOutput.Element]>(value: [])
lazy var elements: Driver<[LoaderOutput.Element]> = { return elementsRelay.asDriver() }()