/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: 2014-07-03 14:41:57 UTC
  • Revision ID: josh@9ix.org-20140703144157-xydxt62xzcdq6bdk
cluke009 zoetrope + my spritebatch changes

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
213
212
 
214
213
                elseif callback and results then
215
 
                        if #results > 1 then
216
 
                                self:fulfill(unpack(results))
 
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
217
223
                        else
218
 
                                self:fulfill(results[1])
 
224
                                -- force failures to receive the same error message we did
 
225
 
 
226
                                local args = {...}
 
227
                                self:fail(args[1])
219
228
                        end
220
229
 
221
 
                -- if there was any kind of error, fail
 
230
                -- and if there was any kind of error, force failure
222
231
 
223
232
                elseif errorMessage then
224
233
                        self:fail(errorMessage)