Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the observing of DataState #62

Open
levibostian opened this issue Nov 24, 2019 · 0 comments
Open

Improve the observing of DataState #62

levibostian opened this issue Nov 24, 2019 · 0 comments

Comments

@levibostian
Copy link
Owner

The iOS version of Teller has recently been updated with a new API for parsing the state of DataState.

Here it is:

repository
    .observe()
    .observeOn(ConcurrentDispatchQueueScheduler(qos: .background))
    .subscribeOn(MainScheduler.instance)
    .subscribe(onNext: { (dataState: DataState<[Repo]>) in
        switch dataState.state() {
        case .noCache(let fetching, let errorDuringFetch):
            // Repos have never been fetched before for the GitHub user.
            break
        case .cache(let cache, let lastFetched, let firstCache, let fetching, let successfulFetch, let errorDuringFetch):
            // Repos have been fetched before for the GitHub user.
            // If `cache` is nil, the cache is empty.
            break
        }
                
        switch dataState.fetchingState() {
        case .fetching(let fetching, let noCache, let errorDuringFetch, let successfulFetch):
            // A new cache could be fetching, just completed fetching, or is not fetching at all.
            break
        }
    })

This is pretty similar to Android's version of Teller with a couple differences:

  1. case cache() has different parameters in it for better understanding the state of the cache.
  2. A new, separate, fetchingState(). This is something I have been wanting to have added to the library has I build more apps with Teller. I find myself handling the fetching state of the data in this fashion where it's a separate function from cache() and noCache().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant