Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Init Simulation
await this.__loadComponent();
if (this.ComponentInstance)
{
// on every intersection
this.ComponentInstance.instance.intersect$.subscribe( (id: string) => this.__updateIntersection(id) );
// begin simulation
timer(100, this._delta)
.pipe(
map( (msec: number): void => {
this._currentStep++;
if (this._currentStep > this._duration) {
this.destroy$.next();
this.destroy$.complete();
}
}),
takeUntil(this.destroy$)
)
.subscribe( () => {
this.ComponentInstance.instance.ngOnChanges({
step: new SimpleChange(this._currentStep-1, this._currentStep, this._currentStep === 1)
});
// run the next simulation step
this.ComponentInstance.instance.next();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment