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

Commit be99d56

Browse files
Merge pull request #774 from deckgo/store
feat(#773): use @stencil/store instead of rxjs
2 parents 3c9a1ee + 7d9e2d3 commit be99d56

File tree

105 files changed

+1857
-2957
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+1857
-2957
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
<a name="1.5.0"></a>
2+
3+
# [1.5.0](https://github.com/deckgo/deckdeckgo/compare/v1.4.0...v1.5.0) (In progress)
4+
5+
### Web Components
6+
7+
- remote: v1.2.0 ([CHANGELOG](https://github.com/deckgo/deckdeckgo/blob/master/webcomponents/remote/CHANGELOG.md))
8+
19
<a name="1.4.0"></a>
210

311
# [1.4.0](https://github.com/deckgo/deckdeckgo/compare/v1.3.0...v1.4.0) (2020-06-25)

docs/package-lock.json

Lines changed: 0 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@
4343
"@deckdeckgo/social": "^1.0.1",
4444
"@deckdeckgo/youtube": "^1.1.2",
4545
"@ionic/core": "^5.2.2",
46-
"idb-keyval": "^3.2.0",
47-
"rxjs": "^6.5.5"
46+
"idb-keyval": "^3.2.0"
4847
},
4948
"devDependencies": {
5049
"@deckdeckgo/types": "^1.1.0",

remote/package-lock.json

Lines changed: 6 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

remote/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
"date-fns": "^2.14.0",
4848
"idb-keyval": "^3.2.0",
4949
"remarkable": "^2.0.1",
50-
"rxjs": "^6.5.5",
5150
"socket.io-client": "^2.3.0",
5251
"uuid": "^8.2.0"
5352
},
@@ -56,6 +55,7 @@
5655
"@stencil/core": "^1.15.0",
5756
"@stencil/postcss": "^1.0.1",
5857
"@stencil/sass": "^1.3.2",
58+
"@stencil/store": "^1.3.0",
5959
"@types/socket.io-client": "^1.4.33",
6060
"@types/w3c-generic-sensor": "^1.0.2",
6161
"@types/webrtc": "0.0.26",

remote/src/app/app-root.tsx

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import {Build, Component, h, State} from '@stencil/core';
22

3-
import {Subscription} from 'rxjs';
4-
53
import {TimerService} from './services/timer/timer.service';
64
import {AccelerometerService} from './services/accelerometer/accelerometer.service';
75
import {ThemeService} from './services/theme/theme.service';
@@ -14,11 +12,8 @@ export class AppRoot {
1412
private timerService: TimerService;
1513
private accelerometerService: AccelerometerService;
1614

17-
private themeSubscription: Subscription;
1815
private themeService: ThemeService;
1916

20-
private domBodyClassList: DOMTokenList = document.body.classList;
21-
2217
@State()
2318
private loading: boolean = true;
2419

@@ -29,10 +24,6 @@ export class AppRoot {
2924
}
3025

3126
async componentWillLoad() {
32-
this.themeSubscription = this.themeService.watch().subscribe((dark: boolean) => {
33-
this.updateDarkModePreferences(dark);
34-
});
35-
3627
await this.themeService.initDarkModePreference();
3728
}
3829

@@ -46,16 +37,8 @@ export class AppRoot {
4637
}
4738
}
4839

49-
componentDidUnload() {
50-
this.timerService.destroy();
51-
52-
if (this.themeSubscription) {
53-
this.themeSubscription.unsubscribe();
54-
}
55-
}
56-
57-
private updateDarkModePreferences(dark: boolean) {
58-
dark ? this.domBodyClassList.add('dark') : this.domBodyClassList.remove('dark');
40+
async componentDidUnload() {
41+
await this.timerService.destroy();
5942
}
6043

6144
render() {

remote/src/app/components/app-header/app-header.tsx

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,16 @@
1-
import {Component, h, State} from '@stencil/core';
1+
import {Component, h} from '@stencil/core';
22

3-
import {Subscription} from 'rxjs';
4-
5-
import {ThemeService} from '../../services/theme/theme.service';
3+
import themeStore from '../../stores/theme.store';
64

75
@Component({
86
tag: 'app-header',
9-
styleUrl: 'app-header.scss'
7+
styleUrl: 'app-header.scss',
108
})
119
export class AppHeader {
12-
private themeSubscription: Subscription;
13-
private themeService: ThemeService;
14-
15-
@State()
16-
private darkTheme: boolean;
17-
18-
constructor() {
19-
this.themeService = ThemeService.getInstance();
20-
}
21-
22-
async componentWillLoad() {
23-
this.themeSubscription = this.themeService.watch().subscribe((dark: boolean) => {
24-
this.darkTheme = dark;
25-
});
26-
}
27-
28-
componentWillUnload() {
29-
if (this.themeSubscription) {
30-
this.themeSubscription.unsubscribe();
31-
}
32-
}
33-
3410
render() {
3511
return (
3612
<ion-header>
37-
<ion-toolbar color={this.darkTheme ? 'dark' : 'primary'}>
13+
<ion-toolbar color={themeStore.state.darkTheme ? 'dark' : 'primary'}>
3814
<slot name="start">
3915
<ion-buttons slot="start">
4016
<ion-menu-toggle>

remote/src/app/components/app-notes/app-notes.tsx

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,24 @@
11
import {Component, h, Listen, State} from '@stencil/core';
22

3-
import {Subscription} from 'rxjs';
3+
import notesStores from '../../stores/notes.store';
44

55
import {Remarkable} from 'remarkable';
66

7-
import {NotesService} from '../../services/notes/notes.service';
8-
97
@Component({
108
tag: 'app-notes',
11-
styleUrl: 'app-notes.scss'
9+
styleUrl: 'app-notes.scss',
1210
})
1311
export class AppNotes {
14-
private notesService: NotesService;
15-
16-
private subscription: Subscription;
12+
private destroyListener;
1713

1814
@State()
1915
private portrait: boolean = true;
2016

2117
@State()
2218
private notes: string;
2319

24-
constructor() {
25-
this.notesService = NotesService.getInstance();
26-
}
27-
2820
componentWillLoad() {
29-
this.subscription = this.notesService.watch().subscribe((element: HTMLElement) => {
21+
notesStores.onChange('currentSlide', (element: HTMLElement) => {
3022
let notes: string = undefined;
3123

3224
if (document && element) {
@@ -36,7 +28,7 @@ export class AppNotes {
3628
const md: Remarkable = new Remarkable({
3729
html: true,
3830
xhtmlOut: true,
39-
breaks: true
31+
breaks: true,
4032
});
4133

4234
const codeRule = (inline: boolean) => (tokens, idx, _options, _env) => {
@@ -63,8 +55,8 @@ export class AppNotes {
6355
}
6456

6557
componentDidUnload() {
66-
if (this.subscription) {
67-
this.subscription.unsubscribe();
58+
if (this.destroyListener) {
59+
this.destroyListener();
6860
}
6961
}
7062

remote/src/app/components/app-stopwatch-time/app-stopwatch-time.tsx

Lines changed: 7 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,24 @@
1-
import {Component, State, h} from '@stencil/core';
1+
import {Component, h} from '@stencil/core';
22

3-
import {BehaviorSubject, Subscription} from 'rxjs';
4-
5-
import {addMilliseconds, formatDistanceStrict} from 'date-fns';
6-
7-
import {TimerInterval, TimerService} from '../../services/timer/timer.service';
3+
import timerStore from '../../stores/timer.store';
84

95
@Component({
106
tag: 'app-stopwatch-time',
11-
styleUrl: 'app-stopwatch-time.scss'
7+
styleUrl: 'app-stopwatch-time.scss',
128
})
139
export class AppStopwatchTime {
14-
private watcherSubscription: Subscription;
15-
private timerSubscription: Subscription;
16-
17-
@State()
18-
private remainingText: string;
19-
20-
@State()
21-
private remainingTime: number = 0;
22-
23-
private timerService: TimerService;
24-
25-
constructor() {
26-
this.timerService = TimerService.getInstance();
27-
}
28-
29-
async componentWillLoad() {
30-
this.watcherSubscription = this.timerService.watch().subscribe((timer: BehaviorSubject<TimerInterval>) => {
31-
if (timer) {
32-
this.timerSubscription = timer.subscribe(
33-
(interval: TimerInterval) => {
34-
if (interval) {
35-
this.remainingTime = interval.timerRemaining;
36-
37-
const end: Date = addMilliseconds(new Date(), this.remainingTime);
38-
this.remainingText = formatDistanceStrict(end, new Date());
39-
} else {
40-
this.remainingTime = 0;
41-
this.remainingText = formatDistanceStrict(new Date(), new Date());
42-
}
43-
},
44-
(_err) => {
45-
// Do nothing
46-
},
47-
async () => {
48-
this.remainingTime = 0;
49-
this.remainingText = formatDistanceStrict(new Date(), new Date());
50-
51-
if (this.timerSubscription) {
52-
this.timerSubscription.unsubscribe();
53-
}
54-
}
55-
);
56-
}
57-
});
58-
}
59-
60-
async componentDidUnload() {
61-
if (this.timerSubscription) {
62-
this.timerSubscription.unsubscribe();
63-
}
64-
65-
if (this.watcherSubscription) {
66-
this.watcherSubscription.unsubscribe();
67-
}
68-
}
69-
7010
render() {
7111
let color: string = 'primary';
72-
if (this.remainingTime >= 30000 && this.remainingTime < 60000) {
12+
if (timerStore.state.remainingTime >= 30000 && timerStore.state.remainingTime < 60000) {
7313
color = 'secondary';
74-
} else if (this.remainingTime < 30000 && this.remainingTime >= 0) {
14+
} else if (timerStore.state.remainingTime < 30000 && timerStore.state.remainingTime >= 0) {
7515
color = 'tertiary';
7616
}
7717

78-
if (this.remainingText) {
18+
if (timerStore.state.remainingText) {
7919
return (
8020
<ion-chip color="danger" style={{background: `var(--ion-color-${color})`, color: 'var(--ion-color-light)'}}>
81-
<ion-label>{this.remainingText}</ion-label>
21+
<ion-label>{timerStore.state.remainingText}</ion-label>
8222
</ion-chip>
8323
);
8424
} else {

0 commit comments

Comments
 (0)