Created
January 4, 2017 00:16
-
-
Save andersonleite/012b7a213f183f44067bcc1c91d1f040 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function model(refreshClickStream$, close1ClickStream$, close2ClickStream$, close3ClickStream$) { | |
var requestStream = refreshClickStream$.startWith('startup click') | |
.map(function() { | |
return 'https://api.punkapi.com/v2/beers'; | |
}); | |
var responseStream = requestStream | |
.flatMap(function(requestUrl) { | |
return Rx.Observable.fromPromise($.getJSON(requestUrl)); | |
}); | |
var suggestion1Stream = createSuggestionStream(refreshClickStream$, responseStream, close1ClickStream$); | |
var suggestion2Stream = createSuggestionStream(refreshClickStream$, responseStream, close2ClickStream$); | |
var suggestion3Stream = createSuggestionStream(refreshClickStream$, responseStream, close3ClickStream$); | |
suggestion1Stream.subscribe(function(suggestedBeer) { | |
renderSuggestion(suggestedBeer, '.suggestion1'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment