Created
August 6, 2015 00:13
-
-
Save igortoliveira/682b587a03e38e895698 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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