Skip to content

Commit

Permalink
Added an auto-resolving init function.
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharyclaysmith committed Feb 27, 2015
1 parent 44d918f commit ee6b0d8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions promises/Promise.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ public class Promise<T:Any> {

}

//SUMMARY: Convenience init to auto-resolve a Promise to a result. This is useful when you already have a result but a function expects a promise.
public convenience init(result:T){
self.init()

resolve(result)
}

// Resolve method.
//
// Returns a resolve function that loops through pending callbacks,
Expand Down

0 comments on commit ee6b0d8

Please sign in to comment.