use of com.facebook.GraphRequestBatch in project react-native-fbsdk by facebook.
the class FBGraphRequestModule method start.
/**
* Send the batch of requests.
* @param requestBatch
* @param timeout
* @param batchCallback
*/
@ReactMethod
public void start(ReadableArray requestBatch, int timeout, Callback batchCallback) {
GraphRequestBatch batch = new GraphRequestBatch();
int potentialID = 0;
int batchID = 0;
synchronized (this) {
do {
batchID = potentialID++;
} while (mResponses.get(batchID) != null);
mResponses.put(batchID, Arguments.createMap());
}
for (int i = 0; i < requestBatch.size(); i++) {
GraphRequest request = buildRequest(requestBatch.getMap(i));
request.setCallback(new GraphRequestCallback(i, batchID));
batch.add(request);
}
batch.setTimeout(timeout);
GraphRequestBatchCallback callback = new GraphRequestBatchCallback(batchID, batchCallback);
batch.addCallback(callback);
batch.executeAsync();
}
Aggregations