Skip to content

Instantly share code, notes, and snippets.

@pulkitkumar
Last active October 25, 2019 09:26
Show Gist options
  • Save pulkitkumar/0db0ae7c66e62133496e2325d1ca33e3 to your computer and use it in GitHub Desktop.
Save pulkitkumar/0db0ae7c66e62133496e2325d1ca33e3 to your computer and use it in GitHub Desktop.
Interview test question.

The following interface fetches articles for an id.

interface NetworkApi {
    /*
     * Fetches details of an article of parameter [id] from the network.
     */  
    fun article(id: String) : Single<Article>
}

The UI needs to show a list of ArticleUi.

class ArticleUi constructor(article: Article) {
    // implementation 
}

Write an Rx chain to get list of ArticleUi from list of Id's.

fun getArticleUi(val ids: List<String>) : Observable<List<ArticleUi>>{
    // your solution.
}

Sample input:

val ids = listOf("id1", "id2", "id3", "id4")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment