Skip to content

Instantly share code, notes, and snippets.

@igortoliveira
Created August 6, 2015 00:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save igortoliveira/682b587a03e38e895698 to your computer and use it in GitHub Desktop.
Save igortoliveira/682b587a03e38e895698 to your computer and use it in GitHub Desktop.
r = divide(3, 0)
r = unwrap(r)
.when('error', function(err) print(err) end)
.when('success', function(r)
r2 = mult(r, 3)
unwrap(r2).when('error')
end)
r = unwrap!(r)
unwrap(r).error(
function(err) print(err) end
).success(
function(r)
r2 = mult(r, 3)
unwrap(r2).when('error')
end
)
function divide(n, d)
if (d == 0) then
return error()
else
return success(n/d)
end
end
unwrap(r).error(
function(err)
dispatch('error.ERROR', err)
end
).success(
function(r)
r2 = mult(r, 3)
unwrap(r2).when('error')
end
)
state.error = {....}
connect('error', handler)
net.http.post('url', {}).success(
function(res)
if (res.status == 'ERROR') then
return error(res.status.errorCode)
end
end
).error(
function(err)
end
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment