SSPromise is an Objective-C implementation of promises, also known as futures, delays or faults.

What are promises?

The basic idea is that instead of a callback returning data, an asynchronous operation should return a temporary value that once the operation completes resolves into the real object, transparently. More information on Wikipedia.

What's different about this implementation?

Many promises are blocking -- that is, accessing the promise will block until it has resolved. I chose to take a different path; if you try to operate on a promise before it's resolved an exception will be thrown. So make sure you check -hasResolved before trying to use a promise.

Aside from its own interface, SSPromise is fully transparent. Messages sent to it will travel through the ObjC forwarding system's fast path (-forwardingTargetForSelector:) to the resolved object. If you need/want to access that object directly use the -force method.

On Snow Leopard, SSPromise has support for block arguments for both resolving the promise and being notified about resolution events.

What's next?

There are a lot of very cool use cases for promises, especially if you subclass SSPromise to make it deal better with specific types of data (images, HTTP responses, etc).


Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.