Ngl: Callback after worker finished

Created on 3 Jun 2016  路  2Comments  路  Source: nglviewer/ngl

Hi again,

Is it possible to run code after an NGL.Worker has finished running?

The example I have in mind is for adding a surface representation. I would like to show a preloader until the surface appears, so that the user knows that something is happening.

I tried using, e.g.:


var structureName = 'structureName';

this.stage.getComponentsByName(structureName).list[0].signals.representationAdded.add( function(repr) {
  console.log('rep added.');
});

But it fires way before surface representations are generated.

All the best,

Harry

question

Most helpful comment

There is a general task counter available in the stage object.

stage.tasks.signals.countChanged.add(function(delta, count){
  // count is > 0 when the surface is still being calculated or a file is loaded
});

All 2 comments

There is a general task counter available in the stage object.

stage.tasks.signals.countChanged.add(function(delta, count){
  // count is > 0 when the surface is still being calculated or a file is loaded
});

Thank you :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

biharck picture biharck  路  6Comments

sunhwan picture sunhwan  路  4Comments

arose picture arose  路  3Comments

harryjubb picture harryjubb  路  4Comments

martingraham picture martingraham  路  4Comments