This file contains 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
__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; |
This file contains 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
getPokemonList( | |
success: { data in | |
self.update(data: data) | |
return KotlinUnit() | |
}, failure: { | |
self.handleError($0?.message) | |
return KotlinUnit() | |
}) |
This file contains 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
getPokemonList( | |
success: { data in | |
self.update(data: data) | |
return KotlinUnit() | |
}, failure: { | |
self.handleError($0?.message) | |
return KotlinUnit() | |
}) |
This file contains 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
class PokeApi { | |
fun getPokemonList(success: (List<PokemonEntry>) -> Unit, failure: (Throwable?) -> Unit) { | |
... | |
} | |
} |
This file contains 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
1. Go to Sublime Text to: Tools -> Build System -> New Build System | |
and put the next lines: | |
{ | |
"cmd": ["python3", "-u", "$file"], | |
"file_regex": "^[ ]File \"(...?)\", line ([0-9]*)", | |
"selector": "source.python" | |
} | |
Then save it with a meaningful name like: python3.sublime-build |
This file contains 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
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() |
This file contains 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
import Foundation | |
protocol Reversible { | |
var isOn: Bool { get set } | |
mutating func reverse() | |
func reversed() -> Self | |
} | |
extension Reversible { |
This file contains 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
class FeedViewController: BaseViewController { | |
//... | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
setupViews() | |
setupBindings() | |
sessionDidUpdate(appCoordinator.session) | |
} |
This file contains 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
import UIKit | |
import Lottie | |
protocol LikeSwitchDelegate: class { | |
func likeSwitch(_ likeSwitch: LikeSwitch, didToggle isSelected: Bool) | |
} | |
class LikeSwitch: UIView { | |
weak var delegate: LikeSwitchDelegate? |
This file contains 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
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() }() |