Iglistkit: Move emptyView API to a property on IGListAdapter

Created on 16 Sep 2016  路  11Comments  路  Source: Instagram/IGListKit

There's really no need for this to be a required method on IGListAdapterDataSource. It could simply be a property, defaulted to nil. When you set the property we use it when the adapter is empty.

Not sure if we need to bother what happens if you set the property _after_ everything has been updated.

proposal

All 11 comments

It could simply be a property...

A property on what? Not clear who the owner would be.

@jessesquires on IGListAdapter I think (or IGListCollectionView)

Ah. But then you'd have to alloc that view upfront (and potentially never use it)

This is true

Closing this as I think lazily loading the empty view, plus changing which view is returned based on state, is a better approach. It leaves us w/ a little more boilerplate but it keeps the functional nature of a lot of the infra.

@rnystrom The empty view is conflict when you using something like this:
https://github.com/aschuch/StatefulViewController

so I hope that wether IGListKit provide a Loading, Error and Empty views or just remove emptyView or keep it optional

How would it conflict with it? I thought StatefulViewController doesn't mess around with the UICollectionView? Does it conflict with their UICollectionViewController hack?

As I always though it would the view state to the view of the UIViewController and not the UICollectionView?

@weyert sorry for not being clear, I mean when I will use StatefulViewController I will not need the emptyView of IGListKit

Yes, so you can just return nil there?

@weyert sure, but it will be confusing to have two different logic to handle empty state, hence the suggestion to make it optional like suggested in the initial issue

I think the idea is to switch away from optional's in the code base (@rnystrom correct?) so maybe it's better to have a default implementation which returns nil

Was this page helpful?
0 / 5 - 0 ratings