From f3353b6e9a470fdc06bb387bf3a40ef81784bed8 Mon Sep 17 00:00:00 2001 From: Alexander Rose <alex.rose@rcsb.org> Date: Mon, 10 Sep 2018 17:23:16 -0700 Subject: [PATCH] fixed units-representation update (don't use async in .forEach) --- .../representation/structure/units-representation.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/mol-geo/representation/structure/units-representation.ts b/src/mol-geo/representation/structure/units-representation.ts index 8b7e9ec5e..d636cd5bd 100644 --- a/src/mol-geo/representation/structure/units-representation.ts +++ b/src/mol-geo/representation/structure/units-representation.ts @@ -30,7 +30,7 @@ export function UnitsRepresentation<P extends StructureProps>(label: string, vis function createOrUpdate(props: Partial<P> = {}, structure?: Structure) { _props = Object.assign({}, _props, props) - return Task.create('Creating or updating StructureRepresentation', async ctx => { + return Task.create('Creating or updating UnitsRepresentation', async ctx => { if (!_structure && !structure) { throw new Error('missing structure') } else if (structure && !_structure) { @@ -97,9 +97,12 @@ export function UnitsRepresentation<P extends StructureProps>(label: string, vis } else { // console.log('no new structure') // No new structure given, just update all visuals with new props. - visuals.forEach(async ({ visual, group }) => { + const visualsList: [ UnitsVisual<P>, Unit.SymmetryGroup ][] = [] // TODO avoid allocation + visuals.forEach(({ visual, group }) => visualsList.push([ visual, group ])) + for (let i = 0, il = visualsList.length; i < il; ++i) { + const [ visual, group ] = visualsList[i] await visual.createOrUpdate(ctx, _props, { group, structure: _structure }) - }) + } } if (structure) _structure = structure }); -- GitLab