androidsyncano

Syncano async query with 'where()' filter


I'm using Syncano latest Android SDK (4.0.6). Is there a way to have a async query with parameters?

Syncano.please(User.class).where()

Doesn't have a method to run it asynchronously.

But

Syncano.getInstance().getObjects(User.class)

Which has 'sendAsync()' but doesn't have 'where()' constrain.

Docs specifies:

Syncano.please(User.class).getAsync(callback);

But I don't see it in code only getAll().


Solution

  • You can make an async call when using please(). Just pass SyncanoCallback object.

       Syncano.please(Item.class).get(new SyncanoListCallback<Item>() {
           @Override
           public void success(ResponseGetList<Item> response, List<Item> result) {
    
           }
    
           @Override
           public void failure(ResponseGetList<Item> response) {
    
           }
       });
    

    You're right that async get() method is missing when using where(). It has to be fixed in the library, but you can make this call anyway saving the reference to RequestBuilder.

       RequestBuilder<Item> please = Syncano.please(Item.class);
       please.where().eq(Item.COLUMN_NUMBER, 11);
       please.get(new SyncanoListCallback<Item>() {
           @Override
           public void success(ResponseGetList<Item> response, List<Item> result) {
    
           }
    
           @Override
           public void failure(ResponseGetList<Item> response) {
    
           }
       });
    

    You can also use where(), without using please(). It will look like this:

       Where<Item> where = new Where<>();
       where.eq(Item.COLUMN_NUMBER, 11);
       Syncano.getInstance().getObjects(Item.class).setWhereFilter(where).sendAsync(new SyncanoListCallback<Item>() {
           @Override
           public void success(ResponseGetList<Item> response, List<Item> result) {
    
           }
    
           @Override
           public void failure(ResponseGetList<Item> response) {
    
           }
       });