SkygearIO / skygear-SDK-Android

Skygear Android SDK
Other
12 stars 36 forks source link

[Lambda] Add Lambda support for Skygear Data Type #230

Open carmenlau opened 6 years ago

carmenlau commented 6 years ago
carmenlau commented 6 years ago

In commit 6db39e56d53cee6a30c5009cd34f30a299d767f7, we get the "result" value from a map is not always true. I found that the result in onSuccess will have key "result" only when the lambda response is array (See onResponse implementation below).

https://github.com/SkygearIO/skygear-SDK-Android/blob/d211958fc11cb01057a134c4d1c14723ea502177/skygear/src/main/java/io/skygear/skygear/Request.java#L106

So in TypedLambdaResponseHandler, result.opt("result") doesn't work when the response is not array. It is not problem of TypedLambdaResponseHandler, it is problem of original lambda response implementation. If response is array, it will return JSONObject with result key. If response is dictionary, result key will be omitted. Since the underlying ResponseHandler onSuccess only accept JSONObject. Should we add onSuccess with JSONArray for the lambda case? We can discuss