Skip to content

Commit

Permalink
Fix fail to call lambda without arguments
Browse files Browse the repository at this point in the history
Refs #276.
  • Loading branch information
Steven-Chan authored Feb 21, 2019
2 parents c7cf8f0 + bba201d commit 3d2e182
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions skygear/src/main/java/io/skygear/skygear/Container.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ public void sendRequest(Request request) {
* @param handler the response handler
*/
public void callLambdaFunction(String name, LambdaResponseHandler handler) {
this.callLambdaFunction(name, (Object[]) null, handler);
LambdaRequest request = new LambdaRequest(name, (Object)null);
request.responseHandler = handler;
this.requestManager.sendRequest(request);
}

/**
Expand All @@ -214,6 +216,10 @@ public void callLambdaFunction(String name, LambdaResponseHandler handler) {
* @param handler the response handler
*/
public void callLambdaFunction(final String name, Object[] args, LambdaResponseHandler handler) {
if (args == null) {
this.callLambdaFunction(name, handler);
return;
}
final String lambdaName = name;
final Object[] lambdaArgs = args;
final LambdaResponseHandler responseHandler = handler;
Expand All @@ -228,7 +234,7 @@ public void onSuccess(List result) {

@Override
public void onFailure(Error error) {

responseHandler.onFail(error);
}
});
}
Expand All @@ -241,6 +247,10 @@ public void onFailure(Error error) {
* @param handler the response handler
*/
public void callLambdaFunction(String name, Map<String, Object> args, LambdaResponseHandler handler) {
if (args == null) {
this.callLambdaFunction(name, handler);
return;
}
final String lambdaName = name;
final Map<String, Object> lambdaArgs = args;
final LambdaResponseHandler responseHandler = handler;
Expand All @@ -255,7 +265,7 @@ public void onSuccess(Map result) {

@Override
public void onFailure(Error error) {

responseHandler.onFail(error);
}
});
}
Expand Down

0 comments on commit 3d2e182

Please sign in to comment.