Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 637
Artem Kislitsyn Avatar asked Jan 27 '16 14:01

Artem Kislitsyn


1 Answers

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.

like image 156
kai Avatar answered Nov 15 '22 04:11

kai