             next(940, 402),
             completed(950),
             ])
-        
+
         XCTAssertEqual(xs.subscriptions, [
             Subscription(200, 900)
             ])
-        
+
         XCTAssertEqual(xs.recordedEvents[2].value.subscriptions, [
             Subscription(300, 760)
             ])
-        
+
         XCTAssertEqual(xs.recordedEvents[3].value.subscriptions, [])
-        
+
         XCTAssertEqual(xs.recordedEvents[4].value.subscriptions, [])
-        
+
         XCTAssertEqual(xs.recordedEvents[5].value.subscriptions, [])
-        
+
         XCTAssertEqual(xs.recordedEvents[6].value.subscriptions, [
             Subscription(850, 950)
             ])
     }
 
 
+    func testFlatMapFirst_Complete_ErrorOuter() {
+        let scheduler = TestScheduler(initialClock: 0)
+
+        let xs = scheduler.createHotObservable([
+            next(5, scheduler.createColdObservable([
+                error(1, testError)
+                ])),
+            next(105, scheduler.createColdObservable([
+                error(1, testError)
+                ])),
+            next(300, scheduler.createColdObservable([
+                next(10, 102),
+                next(90, 103),
+                next(110, 104),
+                next(190, 105),
+                next(440, 106),
+                completed(460)
+                ])),
+            next(400, scheduler.createColdObservable([
+                next(180, 202),
+                next(190, 203),
+                ])),
+            next(550, scheduler.createColdObservable([
+                next(10, 301),
+                next(50, 302),
+                next(70, 303),
+                next(260, 304),
+                next(310, 305),
+                completed(410)
+                ])),
+            next(750, scheduler.createColdObservable([
+                completed(40)
+                ])),
+            next(850, scheduler.createColdObservable([
+                next(80, 401),
+                next(90, 402),
+                completed(100)
+                ])),
+            error(900, testError)
+            ])
+
+        let res = scheduler.start {
+            xs.flatMapFirst { $0 }
+        }
+
+        XCTAssertEqual(res.messages, [
+            next(310, 102),
+            next(390, 103),
+            next(410, 104),
+            next(490, 105),
+            next(740, 106),
+            error(900, testError)
+            ])
+
+        XCTAssertEqual(xs.subscriptions, [
+            Subscription(200, 900)
+            ])
+
+        XCTAssertEqual(xs.recordedEvents[2].value.subscriptions, [
+            Subscription(300, 760)
+            ])
+
+        XCTAssertEqual(xs.recordedEvents[3].value.subscriptions, [])
+
+        XCTAssertEqual(xs.recordedEvents[4].value.subscriptions, [])
+
+        XCTAssertEqual(xs.recordedEvents[5].value.subscriptions, [])
+
+        XCTAssertEqual(xs.recordedEvents[6].value.subscriptions, [
+            Subscription(850, 900)
+            ])
+    }
+
+    func testFlatMapFirst_Error_Inner() {
+        let scheduler = TestScheduler(initialClock: 0)
+
+        let xs = scheduler.createHotObservable([
+            next(5, scheduler.createColdObservable([
+                error(1, testError)
+                ])),
+            next(105, scheduler.createColdObservable([
+                error(1, testError)
+                ])),
+            next(300, scheduler.createColdObservable([
+                next(10, 102),
+                next(90, 103),
+                next(110, 104),
+                next(190, 105),
+                next(440, 106),
+                error(460, testError)
+                ])),
+            next(400, scheduler.createColdObservable([
+                next(180, 202),
+                next(190, 203),
+                completed(205)
+                ])),
+            next(550, scheduler.createColdObservable([
+                next(10, 301),
+                next(50, 302),
+                next(70, 303),
+                next(260, 304),
+                next(310, 305),
+                completed(410)
+                ])),
+            next(750, scheduler.createColdObservable([
+                completed(40)
+                ])),
+            next(850, scheduler.createColdObservable([
+                next(80, 401),
+                next(90, 402),
+                completed(100)
+                ])),
+            completed(900)
+            ])
+
+        let res = scheduler.start {
+            xs.flatMapFirst { $0 }
+        }
+
+        XCTAssertEqual(res.messages, [
+            next(310, 102),
+            next(390, 103),
+            next(410, 104),
+            next(490, 105),
+            next(740, 106),
+            error(760, testError)
+            ])
+
+        XCTAssertEqual(xs.subscriptions, [
+            Subscription(200, 760)
+            ])
+
+        XCTAssertEqual(xs.recordedEvents[2].value.subscriptions, [
+            Subscription(300, 760)
+            ])
+
+        XCTAssertEqual(xs.recordedEvents[3].value.subscriptions, [])
+
+        XCTAssertEqual(xs.recordedEvents[4].value.subscriptions, [])
+
+        XCTAssertEqual(xs.recordedEvents[5].value.subscriptions, [])
+
+        XCTAssertEqual(xs.recordedEvents[6].value.subscriptions, [
+            ])
+    }
+
+    func testFlatMapFirst_Dispose() {
+        let scheduler = TestScheduler(initialClock: 0)
+
+        let xs = scheduler.createHotObservable([
+            next(5, scheduler.createColdObservable([
+                error(1, testError)
+                ])),
+            next(105, scheduler.createColdObservable([
+                error(1, testError)
+                ])),
+            next(300, scheduler.createColdObservable([
+                next(10, 102),
+                next(90, 103),
+                next(110, 104),
+                next(190, 105),
+                next(440, 106),
+                completed(460)
+                ])),
+            next(400, scheduler.createColdObservable([
+                next(180, 202),
+                next(190, 203),
+                completed(205)
+                ])),
+            next(550, scheduler.createColdObservable([
+                next(10, 301),
+                next(50, 302),
+                next(70, 303),
+                next(260, 304),
+                next(310, 305),
+                completed(410)
+                ])),
+            next(750, scheduler.createColdObservable([
+                completed(40)
+                ])),
+            next(850, scheduler.createColdObservable([
+                next(80, 401),
+                next(90, 402),
+                completed(100)
+                ])),
+            completed(900)
+            ])
+
+        let res = scheduler.start(700) {
+            xs.flatMapFirst { $0 }
+        }
+
+        XCTAssertEqual(res.messages, [
+            next(310, 102),
+            next(390, 103),
+            next(410, 104),
+            next(490, 105),
+            ])
+
+        XCTAssertEqual(xs.subscriptions, [
+            Subscription(200, 700)
+            ])
+
+        XCTAssertEqual(xs.recordedEvents[2].value.subscriptions, [
+            Subscription(300, 700)
+            ])
+
+        XCTAssertEqual(xs.recordedEvents[3].value.subscriptions, [])
+
+        XCTAssertEqual(xs.recordedEvents[4].value.subscriptions, [])
+
+        XCTAssertEqual(xs.recordedEvents[5].value.subscriptions, [])
+
+        XCTAssertEqual(xs.recordedEvents[6].value.subscriptions, [])
+    }
+
+    func testFlatMapFirst_SelectorThrows() {
+        let scheduler = TestScheduler(initialClock: 0)
+
+        let xs = scheduler.createHotObservable([
+            next(5, scheduler.createColdObservable([
+                error(1, testError)
+                ])),
+            next(105, scheduler.createColdObservable([
+                error(1, testError)
+                ])),
+            next(300, scheduler.createColdObservable([
+                next(10, 102),
+                next(90, 103),
+                next(110, 104),
+                next(190, 105),
+                next(440, 106),
+                completed(460)
+                ])),
+            next(400, scheduler.createColdObservable([
+                next(180, 202),
+                next(190, 203),
+                completed(205)
+                ])),
+            next(550, scheduler.createColdObservable([
+                next(10, 301),
+                next(50, 302),
+                next(70, 303),
+                next(260, 304),
+                next(310, 305),
+                completed(410)
+                ])),
+            next(750, scheduler.createColdObservable([
+                completed(40)
+                ])),
+            next(850, scheduler.createColdObservable([
+                next(80, 401),
+                next(90, 402),
+                completed(100)
+                ])),
+            completed(900)
+            ])
+
+        var invoked = 0
+        let res = scheduler.start {
+            return xs.flatMapFirst { (x: ColdObservable<Int>) -> ColdObservable<Int> in
+                invoked++
+                if invoked == 2 {
+                    throw testError
+                }
+                return x
+            }
+        }
+
+        XCTAssertEqual(res.messages, [
+            next(310, 102),
+            next(390, 103),
+            next(410, 104),
+            next(490, 105),
+            next(740, 106),
+            error(850, testError)
+            ])
+
+        XCTAssertEqual(xs.subscriptions, [
+            Subscription(200, 850)
+            ])
+
+        XCTAssertEqual(xs.recordedEvents[2].value.subscriptions, [
+            Subscription(300, 760)
+            ])
+
+        XCTAssertEqual(xs.recordedEvents[3].value.subscriptions, [])
+
+        XCTAssertEqual(xs.recordedEvents[4].value.subscriptions, [])
+
+        XCTAssertEqual(xs.recordedEvents[5].value.subscriptions, [])
+
+        XCTAssertEqual(xs.recordedEvents[6].value.subscriptions, [])
+    }
+
+    func testFlatMapFirst_UseFunction() {
+        let scheduler = TestScheduler(initialClock: 0)
+
+        let xs = scheduler.createHotObservable([
+            next(210, 4),
+            next(220, 3),
+            next(250, 5),
+            next(270, 1),
+            completed(290)
+            ])
+
+        let res = scheduler.start {
+            xs.flatMapFirst { (x) in
+                return interval(10, scheduler).map { _ in x } .take(x)
+            }
+        }
+
+        XCTAssertEqual(res.messages, [
+            next(220, 4),
+            next(230, 4),
+            next(240, 4),
+            next(250, 4),
+            next(280, 1),
+            completed(290)
+            ])
+
+        XCTAssertEqual(xs.subscriptions, [
+            Subscription(200, 290)
+            ])
+    }
 }
 
 // MARK: flatMap

        XCTAssertEqual(xs.recordedEvents[3].value.subscriptions, [])

        XCTAssertEqual(xs.recordedEvents[4].value.subscriptions, [])
        
        XCTAssertEqual(xs.recordedEvents[5].value.subscriptions, [])

        XCTAssertEqual(xs.recordedEvents[6].value.subscriptions, [

        ])
    }


    func testFlatMapFirst_Complete_InnerNotComplete() {
        let scheduler = TestScheduler(initialClock: 0)

        let xs = scheduler.createHotObservable([
            next(5, scheduler.createColdObservable([
                error(1, testError)
