CodeCraftersIO / GifWallet

MIT License
0 stars 5 forks source link

Add Loading state to UIViewController #12

Open piercifani opened 5 years ago

piercifani commented 5 years ago

The loading state and the error state of ListState are also used on ViewControllers without a collectionView and it would be useful to add an abstraction that fixes both cases

deceroainfinito commented 5 years ago

Do you mean something like...

protocol HasState: class {
    associatedtype T
    var state: ListState<T> { get set }
}

to apply as:

class CollectionViewStatefulDataSource<Cell: ViewModelReusable & UICollectionViewCell>: NSObject, UICollectionViewDataSource, HasState {
...
}

and also

class GIFCreateViewController: UIViewController, UITableViewDataSource, HasState {
...
}
piercifani commented 5 years ago

Interesting: couple of questions:

piercifani commented 5 years ago

And if we bring this protocol to UIViewController/UIView, maybe we need to rename ListState to just State, right?

deceroainfinito commented 5 years ago

And if we bring this protocol to UIViewController/UIView, maybe we need to rename ListState to just State, right?

Sure. Just "State" would fit better in most scenarios...