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
{ | |
"Version": 1, | |
"Metadata": { | |
"Project": "", | |
"Created": "" | |
}, | |
"Pattern": [ | |
{ | |
"Event": | |
{ |
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 Combine | |
class ChatViewController: UIViewController { | |
var cancellables = Set<AnyCancellable>() | |
let viewModel: ChatViewModel | |
init(viewModel: ChatViewModel) { | |
self.viewModel = viewModel |
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 Combine | |
protocol DiffableListDataSourceType { | |
associatedtype SectionIdentifier: Hashable | |
associatedtype ItemIdentifier: Hashable | |
func apply(_ snapshot: NSDiffableDataSourceSnapshot<SectionIdentifier, ItemIdentifier>, | |
animatingDifferences: Bool, | |
completion: (() -> Void)?) |
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 AdjustableVisualEffectView: UIVisualEffectView { | |
private var animator: UIViewPropertyAnimator! | |
init(effect: UIVisualEffect?, intensity: CGFloat) { | |
super.init(effect: nil) | |
self.animator = UIViewPropertyAnimator(duration: 1, curve: .linear) { [weak self] in | |
self?.effect = effect | |
} | |
self.intensity = intensity |
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 | |
class PixelWidthConstraint: NSLayoutConstraint { | |
override func awakeFromNib() { | |
super.awakeFromNib() | |
constant = 1.0 / UIScreen.main.scale | |
} | |
} |
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 RxSwift | |
import Moya | |
import Unbox | |
public extension ObservableType where E == Response { | |
public func mapObject<T: Unboxable>(type: T.Type) -> Observable<T> { | |
return flatMap { response -> Observable<T> in | |
return Observable.just(try response.mapObject(type: T.self)) | |
} | |
} |
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
protocol ViewModelType { | |
associatedtype Model | |
associatedtype Input | |
init(model: Model, input: Input) | |
} | |
class ViewModel: ViewModelType { |
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
protocol ViewModelType { | |
associatedtype Model | |
associatedtype Input | |
init(model: Model, input: Input) | |
} | |
class ViewModel: ViewModelType { | |
required init(model: Model, input: Input) { |
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
// Neat way of avoiding if lets/guard lets | |
extension Optional { | |
func then(_ handler:(Wrapped) -> Void) { | |
switch self { | |
case .some(let value): handler(value) | |
case .none: break | |
} | |
} |
NewerOlder