Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

Help #652

Closed
asasdasasd opened this issue Feb 20, 2017 · 6 comments
Closed

Help #652

asasdasasd opened this issue Feb 20, 2017 · 6 comments

Comments

@asasdasasd
Copy link

hello, I'm a new comer to RxSwift and Moya. Now I'm reading,learning your code but a little hard to understand, can you write some article just about Auction List this project?

@orta
Copy link
Contributor

orta commented Feb 20, 2017

Hi, we have quite a lot of posts on this project on the Artsy blog: http://artsy.github.io/blog/categories/eidolon/

@asasdasasd
Copy link
Author

I have read some articles, but still can't understand about the detail implementation. Just hope that you can add some notes about Auction List this project in your free time

@ashfurrow
Copy link
Contributor

Hi there, what details are you having a hard time with? By "auction list" do you mean the list of artworks for sale in an auction? It has mostly to do with UICollectionView and isn't the best implementation. If I were writing this from scratch it would use RxDataSources. I'll try to answer any specifics, but my "free time" is quite limited 😉

@asasdasasd
Copy link
Author

https://github.com/artsy/eidolon/blob/master/Kiosk/Auction%20Listings/ListingsViewModel.swift#L93 this is the most hard to deal with, how is it work? It seem that

1. fileprivate func recurringListingsRequest() -> Observable<Array<SaleArtwork>> 
2. fileprivate func allListingsRequest() -> Observable<[SaleArtwork]>
3. fileprivate func retrieveAllListingsRequest(_ page: Int) -> Observable<Any> 
4. fileprivate func listingsRequest(forPage page: Int) -> Observable<Any>

these funcs all have some relationships,how they work together? 🙏

@ashfurrow
Copy link
Contributor

Hmm, yeah those should definitely be better documented 😅 I'll give you a brief description here:

recurringListingsRequest

This is the top-level function that returns an observable that gets all the new listings every 60 seconds. It then checks to see if the number of sale artworks has changed and if so replaces the array, otherwise updates them in-place.

allListingsRequest

This does a few things: it handles scheduling JSON parsing in the background to avoid stalling the UI, bootstraps the initial call to retrieveAllListingsRequest (which is recursive), and concatenates all the results of API calls together into one array.

retrieveAllListingsRequest

A recursive call that fetches a page of sale artworks, and fetches that page + 1 if we got back the same number that we expected to. For example, if there are 41 artworks and we fetch 20 at a time, then we recurse twice: once after the first page, and once after the second. Then the third page returns only one sale artwork so we know we have exhausted the list.

listingsRequest

The simplest one, it just makes the actual network request.


Each one of these does a lot, and if I were writing code fresh I'd break them into their own objects. There's a lot to understand, so it's natural if it feels unfamiliar or intimidating. I'll try my best to answer an specific follow-up questions, but I'm travelling right now and don't have a tonne of availability.

Also, if after studying the file you were to send a PR adding comments explaining everything for the next person, that would be swell. But no pressure!

@ashfurrow
Copy link
Contributor

I think this issue is addressed, so I'm going to close it. Feel free to re-open if you have any follow-up 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants