Add convenience methods to Obj-C for then+catch
lilyball opened this issue · comments
Lily Ballard commented
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;