我想为两个不同的来源发出两个不同的信号,但我在第 29 行遇到
Thread 1: EXC_BAD_ACCESS (code=1, address=0x0)
了RxSwift/Event.swift
崩溃:return "next(\(value))"
这是我的简化代码:
let scheduler = TestScheduler(initialClock: 0)
locationsFactory = TestableLocationsFactory()
locationsFactory.didReceiveRegion = scheduler.createColdObservable([
.next(100, regionEvents[0]),
.next(200, regionEvents[1])
]).asObservable()
locationsFactory.location = scheduler.createColdObservable([
.next(120, locations[0]),
.next(220, locations[1])
]).asObservable()
let result = scheduler.createObserver(LocationChange.self)
let dispatcher = BestAccuracyLocationsDispatcher(persistenceService: persistenceService, apiClient: api, locationManager: locationsFactory)
subscription = dispatcher.dispatcher.subscribe(result)
scheduler.start()
let events = result.events
XCTAssertEqual(events, [
.next(120, LocationChange(location: locations[0], trigger: .updateLocations)),
.next(220, LocationChange(location: locations[1], trigger: .updateLocations)),
])
当我删除locationsFactory.didReceiveRegion
或locationsFactory.location
它工作。
我可以创建两个不同的调度程序的 observables 吗?