I would like to emit two different signals for two different sources, but I get crash
Thread 1: EXC_BAD_ACCESS (code=1, address=0x0)
in RxSwift/Event.swift
in line 29: return "next(\(value))"
this is my simplified code:
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)),
])
When I remove locationsFactory.didReceiveRegion
or locationsFactory.location
it works.
Can I create two different scheduler's observables?
I used mock of region
let region = CLRegion()
which is an abstract class. It started to work when I changed it to:let region = CLCircularRegion(center: CLLocationCoordinate2D(latitude: 5.555, longitude: 6.666), radius: Double(50), identifier: "xxx")