Skip to content

Commit ca21703

Browse files
committed
chore: fix deprecated .subscribe()
1 parent 37f74eb commit ca21703

File tree

4 files changed

+26
-18
lines changed

4 files changed

+26
-18
lines changed

src/app/thingy52/battery-level.component.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@ export class BatteryLevelComponent implements OnInit, OnDestroy {
114114

115115
requestValue() {
116116
this.valuesSubscription = this.service.value()
117-
.subscribe((value: number) => this.updateValue(value), error => this.hasError(error));
117+
.subscribe({
118+
next: (val: number) => this.updateValue(val),
119+
error: (err) => this.hasError(err)
120+
});
118121
}
119122

120123
updateValue(value: number) {

src/app/thingy52/humidity.component.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class HumidityComponent implements OnInit, OnDestroy {
4040
valuesSubscription: Subscription;
4141
streamSubscription: Subscription;
4242

43-
@ViewChild('chart', {static: true})
43+
@ViewChild('chart', { static: true })
4444
chartRef: ElementRef<HTMLCanvasElement>;
4545

4646
get device() {
@@ -62,10 +62,10 @@ export class HumidityComponent implements OnInit, OnDestroy {
6262
this.initChart();
6363

6464
this.streamSubscription = this.service.stream()
65-
.subscribe(
66-
() => this.updateValue.bind(this),
67-
() => of(this.hasError.bind(this)),
68-
);
65+
.subscribe({
66+
next: (val: number) => this.updateValue(val),
67+
error: (err) => this.hasError(err)
68+
});
6969
}
7070

7171
initChart() {
@@ -80,10 +80,10 @@ export class HumidityComponent implements OnInit, OnDestroy {
8080

8181
requestValue() {
8282
this.valuesSubscription = this.service.value()
83-
.subscribe(
84-
() => null,
85-
() => of(this.hasError.bind(this)),
86-
);
83+
.subscribe(
84+
() => null,
85+
() => of(this.hasError.bind(this)),
86+
);
8787
}
8888

8989

src/app/thingy52/stepcounter.component.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,9 @@ const PROVIDERS = [{
3939
text-align: center;
4040
}
4141
mat-icon {
42-
position: absolute;
43-
bottom: 55px;
44-
left: 258px;
45-
font-size: 38px;
42+
font-size: 11em;
43+
width: 100%;
44+
height: 100%;
4645
}`],
4746
providers: PROVIDERS
4847
})
@@ -74,7 +73,10 @@ export class StepCounterComponent implements OnInit, OnDestroy {
7473

7574
ngOnInit() {
7675
this.streamSubscription = this.service.stream()
77-
.subscribe(() => this.updateValue.bind(this), error => this.hasError.bind(this));
76+
.subscribe({
77+
next: (val: { time: number, count: number }) => this.updateValue(val),
78+
error: (err) => this.hasError(err)
79+
});
7880
}
7981

8082
requestValue() {

src/app/thingy52/temperature.component.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class TemperatureComponent implements OnInit, OnDestroy {
4040
valuesSubscription: Subscription;
4141
streamSubscription: Subscription;
4242

43-
@ViewChild('chart', {static: true})
43+
@ViewChild('chart', { static: true })
4444
chartRef: ElementRef<HTMLCanvasElement>;
4545

4646
get device() {
@@ -67,7 +67,10 @@ export class TemperatureComponent implements OnInit, OnDestroy {
6767
this.initChart();
6868

6969
this.streamSubscription = this.service.stream()
70-
.subscribe( () => this.updateValue.bind(this), error => this.hasError.bind(this));
70+
.subscribe({
71+
next: (val: number) => this.updateValue(val),
72+
error: (err) => this.hasError(err)
73+
});
7174
}
7275

7376
initChart() {
@@ -93,7 +96,7 @@ export class TemperatureComponent implements OnInit, OnDestroy {
9396

9497
requestValue() {
9598
this.valuesSubscription = this.service.value()
96-
.subscribe( () => null, error => this.hasError.bind(this));
99+
.subscribe(() => null, error => this.hasError.bind(this));
97100
}
98101

99102
updateValue(value: number) {

0 commit comments

Comments
 (0)