hathway / Parse-PromiseKit

A PromiseKit category for the Parse SDK
Other
29 stars 11 forks source link

Parse+PromiseKit

Parse+PromiseKit is a category that adds PromiseKit integration to the Parse SDK.

Note: The API is subject to change until v1.0.

Installation

Via CocoaPods

Add pod 'Parse+PromiseKit' to your Podfile.

The category for PFFacebookUtils is available as a subspec. Add pod 'Parse+PromiseKit/FacebookUtils' to your Podfile.

Usage

Import Parse+PromiseKit.h or ParseFacebookUtils+PromiseKit.h as appropriate.

Method names prefix Parse's asynchronous method names with promise and remove InBackground, etc. Promises are fulfilled with the same result signature as the appropriate completion block (with a few exceptions).

[object saveInBackground] becomes [object promiseSave]

[user signUpInBackground] becomes [user promiseSignUp]

[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
    if (error) {
        // handle error
    } else {
        // do something with objects
    }
}]

becomes

[query promiseFindObjects].then(^(NSArray *objects) {
    // do something with objects
}).catch(^(NSError *error) {
    // handle error
});

License

Parse+PromiseKit is free software and is released under the Apache v2 license. See LICENSE for more information.

Copyright © 2014 Hathway Inc.