Created
August 1, 2019 19:02
-
-
Save Lavanyagaur22/e042b79f8414d8874ec20b0fdff44bc2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class SampleWorker extends OffixWorker{ | |
public doWork(){ | |
/* getListOfMutations() returns the list of mutations stored in database in the library. | |
It's present in the parent class, i.e OffixWorker. | |
*/ | |
List<Mutation> listOfMutations=getListOfMutations(); | |
//get the mutation one by one from list. | |
for(int i=0;i<listOfMutations.size();i++){ | |
Mutation storedmutation = listOfMutations.get(i); | |
com.apollographql.apollo.api.Mutation<Operation.Data,Operation.Data,Operation.Variables> | |
obj=Offix.getMutation(storedmutation); | |
ApolloMutationCall<Operation.Data> customClient= apolloClient.mutate(obj); | |
customClient?.enqueue(object : ApolloCall.Callback<Operation.Data>() { | |
override fun onFailure(e: ApolloException) { | |
e.printStackTrace() | |
} | |
/* On getting a successful response back from the server, delete mutation from the database. | |
*/ | |
override fun onResponse(response: Response<Operation.Data>) { | |
// Do your work and delete that mutation by calling the deleteMutation() function. | |
deleteMutation(storedmutation) | |
} | |
}) | |
return Result.success(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment