Artem Kislitsyn
Artem Kislitsyn

Reputation: 395

RXSwift How to create wrapper for delegate method with return value

I have a wrapper for delegate in RXSwift

func tableView(tableView: UITableView,movedRowAtIndexPath sourceIndexPath: NSIndexPath,toIndexRowPath destinationRowIndexPath: NSIndexPath)    

And they looks like

public var rx_itemRowMoved: ControlEvent<ItemMovedEvent> {
    let source: Observable<ItemMovedEvent> = rx_delegate.observe("tableView:movedRowAtIndexPath:toIndexRowPath:")
        .map { a in
            return ((a[1] as! NSIndexPath), (a[2] as! NSIndexPath))
    }

    return ControlEvent(events: source)
}

But I have delegate with return value

 func selectionViewForTableView(tableView: UITableView,destinitionCell cell:UITableViewCell,toIndexRowPath destinationRowIndexPath: NSIndexPath) -> UIView

how I can implement wrapper for this delegate ?

Upvotes: 6

Views: 1375

Answers (1)

kai
kai

Reputation: 330

There is no way to do this. You can implement this method in your delegate owner directly. You also can refer to CellFactory of RxTableViewReactiveArrayDataSource. It change the method to block.

Upvotes: 3

Related Questions