Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
paulpdaniels committed Jun 3, 2018
2 parents 592a810 + 868217a commit 05d5ee3
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions examples/6/5/6_5.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@

const gAPILoadAsObservable = Rx.Observable.bindCallback(gapi.load);

const goog$ = url => Rx.Observable.of(url)
const goog$ = url => Rx.Observable.of(url)
.filter(R.compose(R.not, R.isEmpty))
.map(encodeURIComponent)
.switchMap(() => gAPILoadAsObservable('client'))
.do(() => gapi.client.setApiKey(GKEY))
.switchMap(() => Rx.Observable.fromPromise(gapi.client.load('urlshortener', 'v1')))
.switchMap(() => Rx.Observable.fromPromise(gapi.client.urlshortener.url.insert(
{'longUrl': example_url}))
.switchMap(
encodedUri => gAPILoadAsObservable('client')
.do(() => gapi.client.setApiKey(GKEY))
.switchMap(() => Rx.Observable.fromPromise(gapi.client.load('urlshortener', 'v1')))
.switchMap(() => Rx.Observable.fromPromise(
gapi.client.urlshortener.url.insert({'longUrl': encodedUri}))
)
)
.filter(obj => obj.status === 200)
.pluck('result', 'id');
Expand Down

0 comments on commit 05d5ee3

Please sign in to comment.