Inherits from NSObject
Declared in NMBPromise.h

Overview

NMBPromise manages network operations. You can set success/fail callback on it, get progress of it, and more.

Properties

method

The method of the promise. This property describe what does the promise do in a string.

@property (nonatomic, copy) NSString *method

Declared In

NMBPromise.h

progress

The progress of the network operation.

@property (nonatomic, readonly) float progress

Declared In

NMBPromise.h

state

The state of promise, it could be processing, succeeded, failed, cancelled and so on.

@property (nonatomic, readonly) NMBPromiseState state

Declared In

NMBPromise.h

Instance Methods

cancel

Cancel the network operation. Not all kinds of operations can be cancelled.

- (void)cancel

Declared In

NMBPromise.h

fail:

Add a fail callback.

- (instancetype)fail:(NMBPromiseFail)fail

Parameters

fail

The block contains the callback code.

See Also

Declared In

NMBPromise.h

go

After you get an instance of NMBPromise don’t forget to call method go on it, or nothing will happen.

- (void)go

Declared In

NMBPromise.h

initWithUserInfo:

Initialize a newly allocated promise object with the userInfo.

- (id)initWithUserInfo:(NSDictionary *)userInfo

Parameters

userInfo

An instance of NSDictionary that can be access in every blocks of the promise.

Declared In

NMBPromise.h

onQueue:fail:

Add a fail callback on the specific queue.

- (instancetype)onQueue:(dispatch_queue_t)queue fail:(NMBPromiseFail)fail

Parameters

queue

The queue on which the callback will be called. If nil passed, the callback will be run on the main queue.

fail

The block contains the callback code.

See Also

Declared In

NMBPromise.h

onQueue:progress:

Add a progress callback on the specific queue.

- (instancetype)onQueue:(dispatch_queue_t)queue progress:(NMBPromiseProgress)progress

Parameters

queue

The queue on which the callback will be called. If nil passed, the callback will be run on the main queue.

progress

The block contains the callback code.

See Also

Declared In

NMBPromise.h

onQueue:response:

Add a response callback on the specific queue. Will be called in consequence of success or fail.

- (instancetype)onQueue:(dispatch_queue_t)queue response:(NMBPromiseResponse)response

Parameters

queue

The queue on which the callback will be called. If nil passed, the callback will be run on the main queue.

response

The block contains the callback code.

See Also

Declared In

NMBPromise.h

onQueue:success:

Add a success callback on the specific queue.

- (instancetype)onQueue:(dispatch_queue_t)queue success:(NMBPromiseSuccess)success

Parameters

queue

The queue on which the callback will be called. If nil passed, the callback will be run on the main queue.

success

The block contains the callback code.

See Also

Declared In

NMBPromise.h

progress:

Add a progress callback.

- (instancetype)progress:(NMBPromiseProgress)progress

Parameters

progress

The block contains the callback code.

Declared In

NMBPromise.h

response:

Add a response callback. Will be called in consequence of success or fail.

- (instancetype)response:(NMBPromiseResponse)response

Parameters

response

The block contains the callback code.

Declared In

NMBPromise.h

retry

Retry the promise if it is failed.

- (void)retry

Declared In

NMBPromise.h

success:

Add a success callback.

- (instancetype)success:(NMBPromiseSuccess)success

Parameters

success

The block contains the callback code.

Declared In

NMBPromise.h