Making a Ajax Solr widget not synchronous

74 views
Skip to first unread message

junte zhang

unread,
May 29, 2013, 1:55:47 PM5/29/13
to ajax...@googlegroups.com
Dear all,

The Ajax Solr library executes all of its widgets synchronous.

I am wondering whether there is an option to make it asynchronous.

The reason is because I am dealing with a large number of facet fields and the browser freezes while loading.

We add a widget like this:

self.manager.addWidget(new AjaxSolr.TagcloudWidget({
target: '#target',
field: facet
}));

How can I make this call not synchronous and (for example) use the beforeSend to show a loading animation and then on success, show the widget?

Thanks 

James McKinney

unread,
May 29, 2013, 2:51:23 PM5/29/13
to ajax...@googlegroups.com
I'm not sure I understand. Which part are you saying is synchronous?

self.manager.addWidget does this:

widget.manager = this;
this.widgets[widget.id] = widget;

That doesn't take any time at all. Plus, you only run it once when your app first loads. You'd have to be adding thousands/millions of widgets with addWidget to freeze the browser.

As for "new AjaxSolr.TagcloudWidget", the constructor also returns very quickly: https://github.com/evolvingweb/ajax-solr/blob/master/core/AbstractFacetWidget.js#L27

So, there's nothing in that line of code that is slow.

The AJAX request is done asynchronously to prevent network latency and transfer speeds from causing the app the appear slow. The processing of the response is done synchronously - but there is no real alternative. One way or another, that responses needs to get processed. You can either reduce the number of widgets, or use the beforeRequest method on each widget to add a loading animation, and remove the loading animation in the afterRequest method.

James
> --
> You received this message because you are subscribed to the Google Groups "ajax-solr" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ajax-solr+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

junte zhang

unread,
May 30, 2013, 10:10:04 AM5/30/13
to ajax...@googlegroups.com
Hi James,

Sorry, I should have been clearer.

Indeed, I mean the processing of the response. So there is no way to make a part of the processing of the response not synchronous?

For example, it can happen that if the facet count is too large, the browser can freeze. The solution is to limit the response, but I wished there was a way to just process the stuff in the background. 
Alternatively, perhaps split up the response in multiple callbacks and then process.

Cheers

James McKinney

unread,
May 30, 2013, 10:24:16 AM5/30/13
to ajax...@googlegroups.com
But there is no "background" in the browser.

James McKinney

unread,
May 30, 2013, 10:26:58 AM5/30/13
to ajax...@googlegroups.com
If you are doing a lot of processing, let the server do it, i.e. AJAX-Solr is inappropriate if you require a lot of very heavy processing.

junte zhang

unread,
May 30, 2013, 10:32:49 AM5/30/13
to ajax...@googlegroups.com
That's true. But it would be nice if a widget keeps loading while the rest has already loaded.

But I think the limitation is not with the Ajax Solr library. And a solution could be to do extra callbacks and then do the processing externally (server-side) indeed.
Reply all
Reply to author
Forward
0 new messages