I have a method
that returns a Single
:
func getEventStatus() throws -> Single<EventModel?> {
return try mainService.getEventStatus()
}
And I tried to bind
it to a tableView
but got an error
saying that it doesn't work on Singles
, so I tried adding .asObservable()
but now I get the error
Expression type 'Reactive<_>' is ambiguous without more context
I have tried to look up what it means but there doesn't seem to be any consistency to what the error
means, or I can't seem to apply it to my case. This is what the bind
looks like:
viewModel.getEventStatus().asObservable().bind(to: tableView.rx.items(cellIdentifier: EventLogTableViewCell.identifier, cellType: EventLogTableViewCell.self)) { row, data, cell in
cell.viewModel = data
}.disposed(by:disposeBag)
As the method
throws
I added do { try catch{} }
but that doesn't seem to make a difference.
What am I missing here?
The problem is the signature of your method.
The getEventStatus()
method only emits one EventModel
and even that is an Optional
.
The items(cellIdentifier:cellType:)
method requires an Array of things.