FuseViews ICallback ANR

Hi, I found a little problem with Android ICallBack and fat module.exports args. For example If I load this code:

<JavaScript>
var stores = Observable({
            "id": 4,
            "name": "Cycling Shop",
            "description": "La mas destacada tienda de ciclismo, con venta de repuestos y refacciones",
            "profile_image": "http://mydomain,com/img/stores/rueda-libre.jpg",
            "cover_image": "http://mydomain,com/img/stores/rueda-libre-bk.jpg",
            "category_image": "http://mydomain,com/img/categories/tiendas.png",
            "geo_lat": 22.156017,
            "geo_lng": -101.003913,
            "rating": 3,
            "followed": 9
        }, {
            "id": 57,
            "name": "Samba Smoothie",
            "description": "¡Productos naturales, nutritivos y especialmente balanceados para tus actividades diarias!",
            "profile_image": "http://mydomain.com/dynamic/branches/samba-smoothie/profile-image-57.jpg",
            "cover_image": "http://mydomain.com/dynamic/branches/samba-smoothie/cover-image-57.jpg",
            "category_image": "http://mydomain.com/img/categories/restaurantes.png",
            "geo_lat": 22.1478936,
            "geo_lng": -101.0260151,
            "rating": 0,
            "followed": 2
        }
       // ... and more and more stores
   );
}
module.exports = {
  stores : stores
};
</JavaScript>

<Button Clicked="{openStore}" />

Setting the ICallback from Java I get all the module.exports context and it’s painfully slow to trigger the event openStore. The problem is with key “data” of the hashMap(it could be a really long string). Is it possible via Java to hide the datakey? :slight_smile:

DEBUG

Hi jesusmartinoza,

an internal ticket has been raised to investigate the issue. You’ll get notified when there’s some news.

Hi!

Thanks for reporting this issue. We have changed the API for callbacks to lazily load the arguments. The string in the data key is the datacontext from the callsite in UX. Since you are calling out to native code, fuse has to serialize all the data, which can be slow if you have lots of data on the datacontext. In commoncase you dont care about the arguments, but only for the callback itself.

The new API will look like this in Java:

ViewHandle view = ...;
view.setCallback("buttonClicked", new ICallback() {
    @Override
    public void invoke(IEventRecord eventRecord) {
    	// args is whatever described in https://www.fusetools.com/docs/scripting/scripting#binding-functions
    	HashMap<String,String> args = eventRecord.getArgs();
    	// data is the datacontext serialized to a JSON string
    	String data = eventRecord.getDataJson();
    }
});

The serialization will only happen if you call the get methods on eventRecord.

Thank you for the replies! I will try.