This file contains hidden or 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
| viewModel.showLoadingHUD.asDriver(onErrorJustReturn: false) | |
| .drive(onNext: { show in | |
| if show { | |
| HUD.show(.progress) | |
| } else { | |
| HUD.hide() | |
| } | |
| }) | |
| .addDisposableTo(disposeBag) |
This file contains hidden or 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
| // MARK: Submit Button - action | |
| viewModel.loggedIn.asObservable() | |
| .observeOn(MainScheduler.instance) | |
| .retryWhen { errorObservable -> Observable<Error> in | |
| errorObservable.map { [weak self] error in | |
| let alert = ErrorAlertBuilder(error: error).build() | |
| self?.present(alert, animated: true, completion: nil) | |
| return error | |
| } |
This file contains hidden or 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
| // Implementation | |
| import Himotoki | |
| // https://pay.jp/docs/api/#error | |
| struct APIError: Decodable { | |
| let code: APIErrorCode | |
| let message: String | |
| let statusCode: Int | |
| let type: APIErrorType | |
This file contains hidden or 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
| let tearDown = Driver.combineLatest(cancelButton.rx.tap.asDriver(), | |
| viewModel.completetion.asDriver(onErrorJustReturn: false)) { ($0, $1) } | |
| .drive(onNext: { [unowned self] in | |
| HUD.hide() | |
| self.view.endEditing(true) | |
| self.dismiss(animated: true, completion: nil) | |
| }) | |
| tearDown.addDisposableTo(disposeBag) |
This file contains hidden or 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
| // in browser | |
| document.write(jQuery("img.ProfileCard-avatarImage").toArray().reduce((txt, img)=>{ return txt + "\n" + img.src }, "")) | |
| // console | |
| pbpaste | xargs -P 10 wget |
This file contains hidden or 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
| class AmountSettingViewModelSpec: QuickSpec { | |
| override func spec() { | |
| var viewModel: AmountSettingViewModel! | |
| beforeEach { | |
| viewModel = AmountSettingViewModel(amountText: Observable<String>.just("120"), | |
| submitButtonTap: Observable<Void>.just()) | |
| } | |
| it("should be button ebanled") { | |
| let enable = try! viewModel.submitButtonEnable.toBlocking().single() |
This file contains hidden or 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
| import Quick | |
| import Nimble | |
| import RxTest | |
| import RxBlocking | |
| import RxSwift | |
| import RxCocoa | |
| import Result | |
| @testable import customer | |
| class SigninViewModelSpec: QuickSpec { |
This file contains hidden or 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
| let request = UserAPIRequest(id: 1) // APIKit | |
| let username = URLSession.shared.rx.object(request: request) | |
| .map { user in // Himotoki | |
| return user.name | |
| } |
This file contains hidden or 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
| class PersonSpec: QuickSpec { | |
| override func spec() { | |
| describe("Person"){ | |
| describe("成人判定") { | |
| itBehavesLike("is成人") { | |
| let p = Person(name: "_", age: 21) | |
| return ["person": p] | |
| } | |
| itBehavesLike("is成人") { ["person": Person(name: "_", age: 999)] } | |
| itBehavesLike("not成人") { ["person": Person(name: "_", age: 19)] } |
This file contains hidden or 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
| extension Charge { | |
| static var stubObjects: [Charge] { | |
| let JSON = json(from: "Fixtures/charges.json") | |
| return try! decodeArray(JSON, rootKeyPath: "data") | |
| } | |
| } | |
| struct MockWebAPI: HomeAPIProtocol { | |
| func getCharges() -> Observable<[Charge]> { | |
| return Observable.from(Charge.stubObjects) |