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
func testFuture() { | |
let expectation1 = XCTestExpectation(description: self.debugDescription) | |
var cancellables = Set<AnyCancellable>() | |
let future = Future<Int, Error> { promise in | |
promise(.success(42)) | |
} | |
// Future自体は他のPubと全く同じように、Subされて初めて値を放出し始めるのだから、 |
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
share() を消すとどうなるか? | |
=> 購読が1本ではなく、2本発生するので、1も2も両方 valueとfinished を無事受け取れる。 | |
Received data 1: 1256 bytes. | |
Received completion 1: finished. | |
Received data 2: 1256 bytes. | |
Received completion 2: finished. | |
これだとPublisherの生成コストがエコではないから、share()を使ってPublisherを struct => class化し、 |
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
// | |
// ContentView.swift | |
// SwiftyPageControl | |
// | |
// Created by crea on 2019/09/15. | |
// Copyright © 2019 crea. All rights reserved. | |
// | |
import SwiftUI |
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
// | |
// ContentView.swift | |
// NaviGomi | |
// | |
// Created by crea on 2019/09/09. | |
// Copyright © 2019 crea. All rights reserved. | |
// | |
import SwiftUI |
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
tap "fromkk/testsummaries" | |
tap "getsentry/tools" | |
tap "go-delve/delve" | |
tap "homebrew/bundle" | |
tap "homebrew/cask" | |
tap "homebrew/core" | |
tap "homebrew/services" | |
tap "mono0926/license-plist" | |
brew "bitrise" | |
brew "carthage" |
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 UIKit | |
class HogeClass {} | |
// 意味: このプロトコルに適合させるクラスは、 | |
// 必ずこのクラス(HogeClass)のサブクラスでなくてはならない | |
// ≒ HogeClassを継承しないといけない | |
// (Self == HogeClass とは書けない) | |
protocol HogeProtocol where Self: HogeClass { | |
func hoge() |
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
[Q1] | |
let single = Single<Int>.create(subscribe: { (observer) in | |
observer(.success(1)) | |
observer(.success(2)) | |
return Disposables.create() | |
}) | |
_ = single.subscribe(onSuccess: { print($0) }, | |
onError: { print($0) }) |
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 observable = Observable<Int>.empty() | |
observable | |
.subscribe(onCompleted: { print("completedきた") }) | |
.disposed(by: bag) | |
// result | |
"completedきた" |
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 UIKit | |
class StaticClass { | |
static var pokemon = Pokemon(name: "Pikachu") | |
deinit { | |
print("static class died") | |
} | |
} |
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 boss = self.tfBoss.rx.text | |
.map { text -> String in | |
print("はいきた") | |
let t = text ?? "" | |
return t | |
} | |
boss.subscribe(onNext: { text in | |
print("hogehoge1") | |
self.tf1.text = text |
NewerOlder