This file contains hidden or 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 hidden or 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 hidden or 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
| /// Represents a user action which reacts to something | |
| struct Reaction { | |
| let type: ReactionType | |
| let target: ReactionTarget | |
| var isOn: Bool | |
| } | |
| enum ReactionType: String, Decodable { | |
| case heart | |
| case unsupported |
This file contains hidden or 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 | |
| class Cache<T> { | |
| private var dict: [String: T] = [:] | |
| var didSetHandler: ((_ key: String, _ value: T) -> Void)? | |
| func clear() { | |
| dict.removeAll() | |
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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) { | |
| ... | |
| } | |
| } |