Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A port of FuturesJS to Lua / Luvit
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
LICENSE.APACHE2
LICENSE.MIT
README.md
join-test.lua
join.lua
sequence-test.lua
sequence.lua

README.md

Futures-Luvit

A port of the popular FuturesJS to Lua/Luvit.

Sequence

Since then is a reserved word in Lua, the API has been changed ever so slightly.

local timer = require('timer')
local Sequence = require('sequence')
local s

s = Sequence:new()
s:next(function (cb) 
  print('one')
  timer.setTimeout(500, cb)
end)
s:next(function (cb) 
  print('two')
timer.setTimeout(100, cb)
end)
s:next(function () 
  print('three')
end)

API

  • next - enqueue a function to run once the previous function has called cb

Join

local timer = require('timer')
local Join = require('join')
local j

j = Join:new()
-- poop a new callback if you need one
timer.setTimeout(100, j:add())
-- or add callback you've already constructed
j:add(function (cb)
  timer.setTimeout(100, cb)
end)
-- and when all callbacks are done get the arguments back in the right order
-- Huzzah!
j:when(function (...)
  pp({...})
end)

API

  • add - accepts or poops a callback
  • when - enques a final callback to be called once all callbacks have completed

License

Copyright AJ ONeal 2012

This project is available under the MIT and Apache v2 licenses.

Something went wrong with that request. Please try again.