PromiseKit with Swift: terminate chain of promises -


i'm trying use promisekit swift. not familiar it, , there doesn't seem information on usage swift.

i can't seem figure out how terminate chain of promises. long last (terminal) then block contains single statement, fine:

firstly {     // ... }.then { obj in     self.handleresult(obj) }.catch { error in     self.handleerror(error) } 

however, if try add statement, compiler complains:

firstly {     // ... }.then { obj in     self.handleresult(obj)     self.dosomethingdifferent(obj) }.catch { error in // compiler error: missing return in closure expected return 'anypromise'     self.handleerror(error) } 

obviously, solution return promise, doesn't make sense in terminal block. there else can do?

according http://promisekit.org/promisekit-2.0-released/, under swift compiler issues section:

the swift compiler error then. figure out issue, first try specifying full signature closures:

foo.then { x in     doh()     return bar() }  // need written as:  foo.then { obj -> promise<type> in     doh()     return bar() }  // because swift compiler cannot infer closure types // yet. hope fixed.  // watch out  one-line closures though! swift // automatically infer types, may confuse you:  foo.then {     return bar() } 

so you'll have change code to:

firstly {     // ... }.then { obj -> promise<whatevertypedosomethingdifferentpromises> in     self.handleresult(obj)     self.dosomethingdifferent(obj) }.catch { error in     self.handleerror(error) } 

or can use obj -> void stop chain


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -