Performance of dijit/tree when store is dojo/store/Observable

501
0
02-14-2018 04:02 PM
DirkVandervoort
Occasional Contributor II

I am writing an app that contains a dijit/tree. The tree interacts with map selections such that users select features in the map, the selection gets interrogated and child nodes in the dijit/tree get created and populated.

In other words the dijit/tree observes changes to its underlying dojo/store/Memory using dojo/store/Observable (dojo/store/Observable — The Dojo Toolkit - Reference Guide ).

The pattern is below:

var myStore = new Observable(new Memory({data: someData}));
new ObjectStoreModel({store: myStore, query: {id: 'SomeParentNodes'}});
var myTree= new TreeView({
 model: myModel
 }, "someNode");‍‍‍‍‍

Then, after map selections:

array.forEach(selectedFeatureStuff, function(selectedFeatureValue, i){
 myTree.model.store.add(selectedFeatureValue); // ADD
 });

That's pretty slick, except my dijit/tree will typically have hundreds of child nodes (under 5-10 parent nodes). in this scenario, the addition of each child node takes ~0.5 seconds, which means for hundreds of nodes it takes many minutes to fully hydrate the dijit/tree. Unacceptable.

My question is: Is there a way to improve performance here? e.g., turning off Observable just long enough for all the nodes to be created? Or perhaps bulk loading the data store? Or something else entirely. None of the solutions to these options is apparent to me.

TIA

0 Kudos
0 Replies