From ee6b0d8eed796a42d00757c25bed98d0d8702cf6 Mon Sep 17 00:00:00 2001 From: Zach Smith Date: Thu, 26 Feb 2015 16:28:18 -0800 Subject: [PATCH] Added an auto-resolving init function. --- promises/Promise.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/promises/Promise.swift b/promises/Promise.swift index 95f2a86..e365b2c 100644 --- a/promises/Promise.swift +++ b/promises/Promise.swift @@ -44,6 +44,13 @@ public class Promise { } + //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,