diff --git a/src/mol-repr/representation.ts b/src/mol-repr/representation.ts index cdd92dbcce622beba428691e64f8c8bde84a64ac..d271a2f35b28f501a3921444c79394c1f436e1c9 100644 --- a/src/mol-repr/representation.ts +++ b/src/mol-repr/representation.ts @@ -15,7 +15,7 @@ import { getQualityProps } from './util'; import { ColorTheme } from 'mol-theme/color'; import { SizeTheme } from 'mol-theme/size'; import { Theme, ThemeRegistryContext } from 'mol-theme/theme'; -import { BehaviorSubject } from 'rxjs'; +import { Subject } from 'rxjs'; // export interface RepresentationProps { // visuals?: string[] @@ -80,7 +80,7 @@ export interface RepresentationContext { export { Representation } interface Representation<D, P extends PD.Params = {}> { readonly label: string - readonly updated: BehaviorSubject<number> + readonly updated: Subject<number> readonly renderObjects: ReadonlyArray<RenderObject> readonly props: Readonly<PD.Values<P>> readonly params: Readonly<P> @@ -94,7 +94,7 @@ interface Representation<D, P extends PD.Params = {}> { namespace Representation { export type Any = Representation<any> export const Empty: Any = { - label: '', renderObjects: [], props: {}, params: {}, updated: new BehaviorSubject(0), + label: '', renderObjects: [], props: {}, params: {}, updated: new Subject(), createOrUpdate: () => Task.constant('', undefined), getLoci: () => EmptyLoci, mark: () => false, @@ -106,7 +106,8 @@ namespace Representation { export type Def<D, P extends PD.Params = {}> = { [k: string]: (getParams: RepresentationParamsGetter<D, P>) => Representation<any, P> } export function createMulti<D, P extends PD.Params = {}>(label: string, getParams: RepresentationParamsGetter<D, P>, reprDefs: Def<D, P>): Representation<D, P> { - const updated = new BehaviorSubject(0) + let version = 0 + const updated = new Subject<number>() let currentParams: P let currentProps: PD.Values<P> @@ -155,7 +156,7 @@ namespace Representation { await reprList[i].createOrUpdate(ctx, currentProps, currentData).runInContext(runtime) } } - updated.next(updated.getValue() + 1) + updated.next(version++) }) }, getLoci: (pickingId: PickingId) => { diff --git a/src/mol-repr/shape/representation.ts b/src/mol-repr/shape/representation.ts index 87333b0e41e49770e1d229d7c7cd69eca8904635..c8e7ac8db60ea143a510f4358cf3b153cc233f6c 100644 --- a/src/mol-repr/shape/representation.ts +++ b/src/mol-repr/shape/representation.ts @@ -19,7 +19,7 @@ import { PickingId } from 'mol-geo/geometry/picking'; import { MarkerAction, applyMarkerAction } from 'mol-geo/geometry/marker-data'; import { LocationIterator } from 'mol-geo/util/location-iterator'; import { createTheme } from 'mol-theme/theme'; -import { BehaviorSubject } from 'rxjs'; +import { Subject } from 'rxjs'; export interface ShapeRepresentation<P extends ShapeParams> extends Representation<Shape, P> { } @@ -31,7 +31,8 @@ export const ShapeParams = { export type ShapeParams = typeof ShapeParams export function ShapeRepresentation<P extends ShapeParams>(): ShapeRepresentation<P> { - const updated = new BehaviorSubject(0) + let version = 0 + const updated = new Subject<number>() const renderObjects: RenderObject[] = [] let _renderObject: MeshRenderObject | undefined let _shape: Shape @@ -57,7 +58,7 @@ export function ShapeRepresentation<P extends ShapeParams>(): ShapeRepresentatio _renderObject = createMeshRenderObject(values, state) renderObjects.push(_renderObject) - updated.next(updated.getValue() + 1) + updated.next(version++) }); } diff --git a/src/mol-repr/structure/complex-representation.ts b/src/mol-repr/structure/complex-representation.ts index c3b9051ac0989766600760af5d8e0f34ec70d87e..816f84d4ddb0d95897f6930695a1fb6d22a23b35 100644 --- a/src/mol-repr/structure/complex-representation.ts +++ b/src/mol-repr/structure/complex-representation.ts @@ -15,10 +15,11 @@ import { MarkerAction } from 'mol-geo/geometry/marker-data'; import { RepresentationContext, RepresentationParamsGetter } from 'mol-repr/representation'; import { Theme, createTheme } from 'mol-theme/theme'; import { ParamDefinition as PD } from 'mol-util/param-definition'; -import { BehaviorSubject } from 'rxjs'; +import { Subject } from 'rxjs'; export function ComplexRepresentation<P extends StructureParams>(label: string, getParams: RepresentationParamsGetter<Structure, P>, visualCtor: () => ComplexVisual<P>): StructureRepresentation<P> { - const updated = new BehaviorSubject(0) + let version = 0 + const updated = new Subject<number>() let visual: ComplexVisual<P> | undefined let _structure: Structure @@ -38,7 +39,7 @@ export function ComplexRepresentation<P extends StructureParams>(label: string, return Task.create('Creating or updating ComplexRepresentation', async runtime => { if (!visual) visual = visualCtor() await visual.createOrUpdate({ ...ctx, runtime }, _theme, _props, structure) - updated.next(updated.getValue() + 1) + updated.next(version++) }); } diff --git a/src/mol-repr/structure/units-representation.ts b/src/mol-repr/structure/units-representation.ts index aa525857dad38c11a419e7ffc99803ca8b2f6e3e..84aed6c3de81b45c5dd44ff2b813e0b01d2e17dc 100644 --- a/src/mol-repr/structure/units-representation.ts +++ b/src/mol-repr/structure/units-representation.ts @@ -17,7 +17,7 @@ import { MarkerAction } from 'mol-geo/geometry/marker-data'; import { Theme, createTheme } from 'mol-theme/theme'; import { ParamDefinition as PD } from 'mol-util/param-definition'; import { UnitKind, UnitKindOptions } from './visual/util/common'; -import { BehaviorSubject } from 'rxjs'; +import { Subject } from 'rxjs'; export const UnitsParams = { ...StructureParams, @@ -28,7 +28,8 @@ export type UnitsParams = typeof UnitsParams export interface UnitsVisual<P extends UnitsParams> extends Visual<StructureGroup, P> { } export function UnitsRepresentation<P extends UnitsParams>(label: string, getParams: RepresentationParamsGetter<Structure, P>, visualCtor: () => UnitsVisual<P>): StructureRepresentation<P> { - const updated = new BehaviorSubject(0) + let version = 0 + const updated = new Subject<number>() let visuals = new Map<number, { group: Unit.SymmetryGroup, visual: UnitsVisual<P> }>() let _structure: Structure @@ -120,7 +121,7 @@ export function UnitsRepresentation<P extends UnitsParams>(label: string, getPar } } if (structure) _structure = structure - updated.next(updated.getValue() + 1) + updated.next(version++) }); } @@ -169,7 +170,7 @@ export function UnitsRepresentation<P extends UnitsParams>(label: string, getPar }, get props() { return _props }, get params() { return _params }, - get updated() { return updated }, + updated, createOrUpdate, getLoci, mark, diff --git a/src/mol-repr/volume/representation.ts b/src/mol-repr/volume/representation.ts index 81e7d1ad09b81a4c4f7b327c574ebd6b6078abe1..075c02c8a417f4671251242aeac212d5387d6132 100644 --- a/src/mol-repr/volume/representation.ts +++ b/src/mol-repr/volume/representation.ts @@ -20,7 +20,7 @@ import { NullLocation } from 'mol-model/location'; import { VisualUpdateState } from 'mol-repr/util'; import { ValueCell } from 'mol-util'; import { Theme, createTheme } from 'mol-theme/theme'; -import { BehaviorSubject } from 'rxjs'; +import { Subject } from 'rxjs'; export interface VolumeVisual<P extends VolumeParams> extends Visual<VolumeData, P> { } @@ -143,7 +143,8 @@ export const VolumeParams = { export type VolumeParams = typeof VolumeParams export function VolumeRepresentation<P extends VolumeParams>(label: string, getParams: RepresentationParamsGetter<VolumeData, P>, visualCtor: (volume: VolumeData) => VolumeVisual<P>): VolumeRepresentation<P> { - const updated = new BehaviorSubject(0) + let version = 0 + const updated = new Subject<number>() let visual: VolumeVisual<P> let _volume: VolumeData @@ -177,7 +178,7 @@ export function VolumeRepresentation<P extends VolumeParams>(label: string, getP await visual.createOrUpdate({ ...ctx, runtime }, _theme, _props, volume) busy = false } - updated.next(updated.getValue() + 1) + updated.next(version++) }); }