Project implementation

We will start by implementing a repositoriesBy() helper method that will take a Github ID parameter and return an Observable of array of Repository. In a production app, we would put this functionality in an APIManager, but we are intentionally doing this in one file to make it easier to follow. First, we will guard that the GitHub ID parameter is not empty, and then we will successfully create a URL to use our fetch request, as follows:

static func repositoriesBy(_ githubID: String) -> Observable<[Repository]> {        guard !githubID.isEmpty,            let url = URL(string: "https://api.github.com/users/\(githubID)/repos") else {            return Observable.just([])         }    }

If the creation of the URL fails, we will return just an empty array of ...

Get Reactive Programming with Swift 4 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.