MBEvents(DataLoading) Category Reference

Declared in MBEvents+DataLoading.h

Overview

This MBEvents class category adds methods for managing events related to the asynchronous loading of data.

Constructing event names

+ willRequestDataEventName:

Constructs the name of the event that is fired when an asynchronous data load attempt is about to begin.

+ (nonnull NSString *)willRequestDataEventName:(nonnull NSString *)name

Parameters

name

The name of the data item being requested.

Return Value

The name of the event fired when the data item named name is about to be requested.

Declared In

MBEvents+DataLoading.h

+ dataLoadedEventName:

Constructs the name of the event that is fired when an asynchronous data load completes successfully.

+ (nonnull NSString *)dataLoadedEventName:(nonnull NSString *)name

Parameters

name

The name of the data item that was loaded.

Return Value

The name of the event fired when the data item named name loads successfully.

Declared In

MBEvents+DataLoading.h

+ dataLoadFailedEventName:

Constructs the name of the event that is fired when an asynchronous data load attempt fails.

+ (nonnull NSString *)dataLoadFailedEventName:(nonnull NSString *)name

Parameters

name

The name of the data item that failed to load.

Return Value

The name of the event fired when the data item named name fails to load.

Declared In

MBEvents+DataLoading.h

Posting specific events

+ postWillRequestData:

Posts an event indicating that an asynchronous data load attempt is about to begin.

+ (void)postWillRequestData:(nonnull NSString *)name

Parameters

name

The name of the data item being requested.

Discussion

The name of the NSNotification event fired is constructed based on the parameter name, and is constructed as: “name:willRequestData”.

In addition, when this event is fired, a boolean Mockingbird variable with the name “name:requestPending” will be set to true, and the value of the variable named “name:lastRequestFailed” will be unset.

Declared In

MBEvents+DataLoading.h

+ postDataLoaded:

Posts an event indicating that an asynchronous data load completed successfully.

+ (void)postDataLoaded:(nonnull NSString *)name

Parameters

name

The name of the data item that was loaded.

Discussion

The name of the NSNotification event fired is constructed based on the parameter name, and is constructed as: “name:dataLoaded”.

In addition, when this event is fired, the Mockingbird variable with the name “name:requestPending” will be unset.

Declared In

MBEvents+DataLoading.h

+ postDataLoadFailed:withError:

Posts an event indicating that an asynchronous data load failed.

+ (void)postDataLoadFailed:(nonnull NSString *)name withError:(nonnull NSError *)error

Parameters

name

The name of the data item that failed to load.

error

An error object representing the nature of the failure.

Discussion

The name of the NSNotification event fired is constructed based on the parameter name, and is constructed as: “name:dataLoadFailed”.

In addition, when this event is fired, a boolean Mockingbird variable with the name “name:lastRequestFailed” will be set to true, and the value of the variable named “name:requestPending” will be unset.

Declared In

MBEvents+DataLoading.h

+ postWillRequestData:withEventObject:

Posts an event indicating that an asynchronous data load attempt is about to begin.

+ (void)postWillRequestData:(nonnull NSString *)name withEventObject:(nullable id)eventObj

Parameters

name

The name of the data item being requested.

eventObj

An object to include as the value of the NSNotification’s object property.

Discussion

The name of the NSNotification event fired is constructed based on the parameter name, and is constructed as: “name:willRequestData”.

In addition, when this event is fired, a boolean Mockingbird variable with the name “name:requestPending” will be set to true, and the value of the variable named “name:lastRequestFailed” will be unset.

Declared In

MBEvents+DataLoading.h

+ postDataLoaded:withEventObject:

Posts an event indicating that an asynchronous data load completed successfully.

+ (void)postDataLoaded:(nonnull NSString *)name withEventObject:(nullable id)eventObj

Parameters

name

The name of the data item that was loaded.

eventObj

An object to include as the value of the NSNotification’s object property.

Discussion

The name of the NSNotification event fired is constructed based on the parameter name, and is constructed as: “name:dataLoaded”.

In addition, when this event is fired, the Mockingbird variable with the name “name:requestPending” will be unset.

Declared In

MBEvents+DataLoading.h

+ postDataLoadFailed:withError:eventObject:

Posts an event indicating that an asynchronous data load failed.

+ (void)postDataLoadFailed:(nonnull NSString *)name withError:(nonnull NSError *)error eventObject:(nullable id)eventObj

Parameters

name

The name of the data item that failed to load.

error

An error object representing the nature of the failure.

eventObj

An object to include as the value of the NSNotification’s object property.

Discussion

The name of the NSNotification event fired is constructed based on the parameter name, and is constructed as: “name:dataLoadFailed”.

In addition, when this event is fired, a boolean Mockingbird variable with the name “name:lastRequestFailed” will be set to true, and the value of the variable named “name:requestPending” will be unset.

Declared In

MBEvents+DataLoading.h