Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.

Commit 2a756f5

Browse files
feat(#773): remove rxjs interval
1 parent cdfe81d commit 2a756f5

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

studio/src/app/components/editor/styles/deck/app-deck-transition/app-deck-transition.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import {Component, Element, Event, EventEmitter, Prop, h, State} from '@stencil/core';
22

3-
import {interval, Subscription} from 'rxjs';
4-
53
@Component({
64
tag: 'app-deck-transition',
75
styleUrl: 'app-deck-transition.scss',
@@ -17,7 +15,8 @@ export class AppDeckTransition {
1715
@State()
1816
private selectedTransition: 'slide' | 'fade' | 'none';
1917

20-
private timerSubscription: Subscription;
18+
private timerInterval: NodeJS.Timeout;
19+
private timerCounter: number = 0;
2120

2221
async componentWillLoad() {
2322
await this.initSelectedTransition();
@@ -28,8 +27,8 @@ export class AppDeckTransition {
2827
}
2928

3029
componentDidUnload() {
31-
if (this.timerSubscription) {
32-
this.timerSubscription.unsubscribe();
30+
if (this.timerInterval) {
31+
clearInterval(this.timerInterval);
3332
}
3433
}
3534

@@ -48,19 +47,21 @@ export class AppDeckTransition {
4847
}
4948

5049
private async animateDecks() {
51-
this.timerSubscription = interval(2000).subscribe(async (val: number) => {
50+
this.timerInterval = setInterval(async () => {
5251
const elements: NodeListOf<HTMLElement> = this.el.querySelectorAll('deckgo-deck');
5352

5453
if (elements) {
5554
for (const element of Array.from(elements)) {
56-
if (val % 2 === 0) {
55+
if (this.timerCounter % 2 === 0) {
5756
await (element as any).slideNext();
5857
} else {
5958
await (element as any).slidePrev();
6059
}
6160
}
6261
}
63-
});
62+
63+
this.timerCounter++;
64+
}, 2000);
6465
}
6566

6667
private applyTransition(transition: 'slide' | 'fade' | 'none'): Promise<void> {

studio/src/app/popovers/editor/app-create-slide/app-create-slide.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import {Component, Element, Event, EventEmitter, h, JSX, State} from '@stencil/core';
22

3-
import {interval, Subscription} from 'rxjs';
4-
53
import deckStore from '../../../stores/deck.store';
64
import authStore from '../../../stores/auth.store';
75
import userStore from '../../../stores/user.store';
@@ -50,7 +48,8 @@ export class AppCreateSlide {
5048

5149
@Event() signIn: EventEmitter<void>;
5250

53-
private timerSubscription: Subscription;
51+
private timerInterval: NodeJS.Timeout;
52+
private timerCounter: number = 0;
5453

5554
private config: EnvironmentDeckDeckGoConfig = EnvironmentConfigService.getInstance().get('deckdeckgo');
5655

@@ -73,8 +72,8 @@ export class AppCreateSlide {
7372
}
7473

7574
private unsubscribeTimer() {
76-
if (this.timerSubscription) {
77-
this.timerSubscription.unsubscribe();
75+
if (this.timerInterval) {
76+
clearInterval(this.timerInterval);
7877
}
7978
}
8079

@@ -205,15 +204,17 @@ export class AppCreateSlide {
205204

206205
this.unsubscribeTimer();
207206

208-
this.timerSubscription = interval(2000).subscribe(async (val: number) => {
207+
this.timerInterval = setInterval(async () => {
209208
const elements: NodeListOf<HTMLElement> = this.el.querySelectorAll('deckgo-slide-chart[animation]');
210209

211210
if (elements) {
212211
for (const element of Array.from(elements)) {
213-
await (element as any).beforeSwipe(val % 2 === 0, true);
212+
await (element as any).beforeSwipe(this.timerCounter % 2 === 0, true);
214213
}
215214
}
216-
});
215+
216+
this.timerCounter++;
217+
}, 2000);
217218
}
218219

219220
private async selectElement(slotType: SlotType) {

0 commit comments

Comments
 (0)