Skip to content

Instantly share code, notes, and snippets.

@theAlgorithmist
Created March 27, 2020 22:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theAlgorithmist/7b6b1dbb2e07068690fedff5e6350b04 to your computer and use it in GitHub Desktop.
Save theAlgorithmist/7b6b1dbb2e07068690fedff5e6350b04 to your computer and use it in GitHub Desktop.
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