/ld27

To get this branch, use:
bzr branch http://9ix.org/bzr/ld27

« back to all changes in this revision

Viewing changes to zoetrope/core/promise.lua

  • Committer: Josh C
  • Date: 2013-08-25 00:32:21 UTC
  • Revision ID: josh@9ix.org-20130825003221-632jbug07yhqabuo
pickĀ upĀ goals

Show diffs side-by-side

added added

removed removed

Lines of Context:
209
209
                if results and type(results[1]) == 'table' and results[1].instanceOf and results[1]:instanceOf(Promise) then
210
210
                        results[1]:andThen(function(...) self:fulfill(...) end, function(errorMessage) self:fail(errorMessage) end)
211
211
 
 
212
                -- if the callback returned a regular value, fulfill the promise
212
213
 
213
214
                elseif callback and results then
214
 
                        -- fulfill or progress the promise as requested, with the returned value(s)
215
 
                        -- (note simulated colon calling syntax)
216
 
 
217
 
                        if defaultAction ~= 'fail' then
218
 
                                if #results > 1 then
219
 
                                        self[defaultAction](self, unpack(results))
220
 
                                else
221
 
                                        self[defaultAction](self, results[1])
222
 
                                end
 
215
                        if #results > 1 then
 
216
                                self:fulfill(unpack(results))
223
217
                        else
224
 
                                -- force failures to receive the same error message we did
225
 
 
226
 
                                local args = {...}
227
 
                                self:fail(args[1])
 
218
                                self:fulfill(results[1])
228
219
                        end
229
220
 
230
 
                -- and if there was any kind of error, force failure
 
221
                -- if there was any kind of error, fail
231
222
 
232
223
                elseif errorMessage then
233
224
                        self:fail(errorMessage)