Created
January 17, 2017 19:04
-
-
Save vitorventurin/3e1d1b02ebb4050a949205647102c9c9 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
// | |
// PlaceViewModel.swift | |
// RxPlaces | |
// | |
// Created by Vitor Venturin Linhalis on 17/01/17. | |
// Copyright © 2017 Vitor Venturin Linhalis. All rights reserved. | |
// | |
import UIKit | |
import RxSwift | |
import Moya | |
class PlaceViewModel: NSObject { | |
var places:[Place]! = [] | |
var rxPlaces:Variable<[Place]>! = Variable([]) | |
var pagetoken:String? | |
var disposeBag:DisposeBag! = DisposeBag() | |
var provider:RxMoyaProvider<GooglePlaces>! = RxMoyaProvider<GooglePlaces>() | |
func loadPlaces(_ location: String, type: Type, radius: Int) -> Observable<Result> { | |
return self.provider! | |
.request(.getPlaces(location: location, type: type, radius: radius, key: GooglePlacesAPI.token)) | |
.mapObject(type: Result.self) | |
} | |
func nextPage(_ pagetoken: String) -> Observable<Result> { | |
return self.provider! | |
.request(.getNextPage(nextPageToken: pagetoken, key: GooglePlacesAPI.token)) | |
.mapObject(type: Result.self) | |
.observeOn(MainScheduler.instance) | |
} | |
// losAngeles = "34.052235,-118.243683" (latitude, longitude) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment