Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serialize load requests #356

Closed
exteon opened this issue Nov 25, 2014 · 2 comments
Closed

Serialize load requests #356

exteon opened this issue Nov 25, 2014 · 2 comments
Assignees

Comments

@exteon
Copy link

exteon commented Nov 25, 2014

Hello,
I have the following problem: I'm trying to merge fancytree into a text search widget. When the user types, there are possibly overlapping calls to reload(url). These cause 2 problems: the tree becomes out of sync with the load requests and some error is triggered at jQuery level (Assertion failed: only init supported). I have 2 workarounds for it, either load the JSON data externally with a proper serialization check and call reload(object), or delay reloads while the tree is not done reloading. It would be nice though if this would be implemented internally in fancytree (assign an id to every reload() call, propagate via closure to XHR complete callback, then silently discard XHR responses that are not the latest).

@mar10
Copy link
Owner

mar10 commented Dec 1, 2014

Currently I feel that this is a bit out of scope for fancytree, since 'source' accept many other formats, not just xhr. Also it can not reliably be cancelled (http://stackoverflow.com/a/4551178/19166):

If the request has already been sent to the server then the server will process the request even if we abort the request but the client will not wait for/handle the response.

I think that there may be other tools to prevent this beforehand, e.g. Debounce (http://benalman.com/code/projects/jquery-throttle-debounce/examples/debounce/)

@mar10 mar10 closed this as completed Dec 1, 2014
@exteon
Copy link
Author

exteon commented Dec 9, 2014

Indeed, the request cannot be canceled but can be quietly discarded. The issue is that any external handling will not have control over fancytree interface (ie, nice rotating progress circle); an internal implementation (as basic as it may be) would be much more user-friendly. Also, with an external handling (which we have done) there is this issue: the tree processing (using reload) is by your implementation async (and it should be), therefore a second reload() must be delayed after the current tree processing is complete (after the complete event), otherwise it will cause errors. This has nothing to do with XHR response order, it happens with static reload()'s as well, so it's pretty difficult to avoid without making a wrapper for fancytree, which is obviously fancytree specific (debounce won't handle this, that just serializes XHR requests). It would be nice if at least this second point would be resolved in some manner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants