Skip to content

Instantly share code, notes, and snippets.

View alanpaivaa's full-sized avatar
🏠
Working from home

Alan Paiva alanpaivaa

🏠
Working from home
View GitHub Profile
@alanpaivaa
alanpaivaa / pyg_setup.sh
Created February 19, 2021 11:52 — forked from AnirudhDagar/pyg_setup.sh
PyTorch Geometric Setup Script for Mac OS X
# Works on OS X, with conda installed.
# Create conda environment for PyTorch Geometric
echo "Creating pyg environment"
conda create -n pyg python=3.6
echo "Activate pyg Env"
source activate pyg
# PyTorch Conda Installation
let dataObservable = Observable<String>.create { observer -> Disposable in
print("Feching data...")
DispatchQueue.global(qos: .background).asyncAfter(deadline: .now() + 2, execute: {
observer.onNext("Some data from the internet")
})
return Disposables.create()
}
let dataDriver = dataObservable.asDriver(onErrorJustReturn: "")
Subscription A -> 0
----- t1 -----
Subscription A -> 1
----- t2 -----
Subscription B -> 0
Subscription B -> 1
Subscription A -> 2
Subscription B -> 2
Subscription A -> 0
----- t1 -----
Subscription A -> 1
----- t2 -----
Subscription B -> 0
Subscription B -> 1
Subscription A -> 2
Subscription B -> 2
_ = printSecondBoundary()
let intSequence = Observable<Int>
.interval(.seconds(1), scheduler: MainScheduler.instance)
.share(replay: 2, scope: .whileConnected)
var subscriptionA = intSequence.printNext("Subscription A")
var subscriptionB: Disposable?
delay(3) { subscriptionB = intSequence.printNext("Subscription B") }
delay(4) { subscriptionA.dispose() }
delay(5) { subscriptionB?.dispose() }
Subscription A -> 0
----- t1 -----
Subscription A -> 1
----- t2 -----
Subscription B -> 0
Subscription B -> 1
Subscription A -> 2
Subscription B -> 2
_ = printSecondBoundary()
let intSequence = Observable<Int>.interval(.seconds(1), scheduler: MainScheduler.instance).share(replay: 2)
_ = intSequence.printNext("Subscription A")
delay(3) { _ = intSequence.printNext("Subscription B") }
Creating observable
Multiplying by 2
Subscription A -> 4
Subscription B -> 4
let observable = Observable<Int>.create { observer -> Disposable in
print("Creating observable")
DispatchQueue.global(qos: .background).asyncAfter(deadline: .now() + 1, execute: {
observer.onNext(2)
}
return Disposables.create()
}
let doubleObservable = observable.map { value -> Int in
print("Multiplying by 2")
I guess I'll never come back here...: NEGATIVE
The view from where I was sit was just amazing: POSITIVE
The waiter was very friendly and kind: POSITIVE
The fish was rotten :/: NEGATIVE
Jon Snow is the King in the North!: POSITIVE