Skip to content

Instantly share code, notes, and snippets.

View srstanic's full-sized avatar

Srđan Stanić srstanic

View GitHub Profile
@srstanic
srstanic / RealmMultiThreadingStaleDataTests.swift
Created March 15, 2022 14:55
RealmMultiThreadingStaleDataTests.swift
import XCTest
import Combine
import RealmSwift
class RealmMultiThreadingStaleDataTests: XCTestCase {
private var cancellables: Set<AnyCancellable>!
override func setUpWithError() throws {
super.setUp()
cancellables = []
@srstanic
srstanic / MyCollectionViewController1.swift
Created February 28, 2023 12:47
MyCollectionViewController #1
import UIKit
struct CollectionItemModel {
let title: String?
let image: UIImage?
}
/// First set `model` and then present on screen.
final class MyCollectionViewController: UICollectionViewController {
var models: [CollectionItemModel]?
@srstanic
srstanic / MyCollectionViewController2.swift
Created February 28, 2023 12:49
MyCollectionViewController #2
import UIKit
struct CollectionItemModel {
let title: String?
let image: UIImage?
}
struct CellController {
var model: CollectionItemModel
func getCell(collectionView: UICollectionView, indexPath: IndexPath) -> UICollectionViewCell {
@srstanic
srstanic / MyCollectionViewController3.swift
Created February 28, 2023 12:53
MyCollectionViewController #3
import UIKit
protocol CellController {
func getCell(collectionView: UICollectionView, indexPath: IndexPath) -> UICollectionViewCell
}
struct TextItemModel {
let title: String
}
// Presenter
typealias SomeViewModel = String // this is just a placeholder for your view model type
protocol SomeView {
func showSomething(viewModel: SomeViewModel)
}
protocol SomeViewOutput {
func onUserAction()
enum LoadableContentState<LoadedContentType, ErrorContentType> {
case loading
case loaded(content: LoadedContentType)
case error(content: ErrorContentType)
}
// error content for the transactions list screen
struct TransactionsListLoadingErrorContent {
let title: String
let subtitle: String