lilyball / Tomorrowland

Lightweight Promises for Swift & Obj-C

Home Page:https://lilyball.github.io/Tomorrowland/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add convenience methods to Obj-C for then+catch

lilyball opened this issue · comments

The Obj-C API is a little awkward with the nested method calls thanks to Obj-C messaging style. We might want to consider adding the following methods for convenience:

- (TWLPromise *)then:(void (^)(ValueType value))thenHandler catch:(void (^)(ErrorType error))catchHandler;

- (TWLPromise *)onContext:(TWLContext *)context then:(void (^)(ValueType value))thenHandler catch:(void (^)(ErrorType error))catchHandler;
- (TWLPromise *)onContext:(TWLContext *)context token:(nullable TWLInvalidationToken *)token then:(void (^)(ValueType value))thenHandler catch:(void (^)(ErrorType error))catchHandler;

- (TWLPromise *)then:(void (^)(ValueType value))thenHandler catch:(void (^)(ErrorType error))catchHandler whenCancelled:(void (^)(void))cancelHandler;
- (TWLPromise *)onContext:(TWLContext *)context then:(void (^)(ValueType value))thenHandler catch:(void (^)(ErrorType error))catchHandler whenCancelled:(void (^)(void))cancelHandler;
- (TWLPromise *)onContext:(TWLContext *)context token:(nullable TWLInvalidationToken *)token then:(void (^)(ValueType value))thenHandler catch:(void (^)(ErrorType error))catchHandler whenCancelled:(void (^)(void))cancelHandler;