Using front-end timout with jsTree

35 Views Asked by At

I have a web-application which is presenting data collected directly from an external API. To present the data, I'm using jsTree as the visual front-end plugin. The front-end element is defined like this:

("#dataTree").jstree({
  "core": {
    multiple: false,
    "themes": {
      "responsive": false
    },
    // so that create works
    "check_callback": true,
    "data": {
      "url": function (node) {
        return node.id === '#' ?
          "Some URL" :
          "Different URL";
      },      
      "data": function (node) {
        var sharePointId = '';
        if (node.original !== undefined) {
          sharePointId = node.original.rootElementId;
        }
        return {
          "parentId": node.id,
          "parentType": node.type,
          "childId": childId
        };
      }
    }
  },
  "types": {
    "default": {
      "icon": "fas fa-archive text-primary"
    },
    "Instance": {
      "icon": "fas fa-box text-primary"
    },
    "Folder": {
      "icon": "fa fa-folder  text-primary"
    },
    "Content": {
      "icon": "fas fa-list  text-primary"
    },
    "Child": {
      "icon": "fas fa-sitemap  text-primary"
    }
  },
  "state": {
    "key": "dataTree"
  },
  "plugins": ["dnd", "state", "types"]
});

The problem is that the external API is rather inconsistent regarding performance. At this moment this is unfortunatelly pretty much a given. Most of the time this works fine (performance ignored), but from time to time the performance is so bad, that the jsTree plugin cannot load the data anymore. The back-end can still be going, but the front-end (jsTree) is throwing a timeout.

I'm trying to figure out if I can declare the jsTree element so that it ignores the timeout, and letting the front-end be 'loading' as long as the back-end is fetching the data, but this is where the jsTree documentation falls short (or I can't find it (a bit more probable)). Is this even possible, and if so, how is this achieved?

0

There are 0 best solutions below