Skip to content

Commit 4fab5e1

Browse files
committed
visualized node log via toast
1 parent f646517 commit 4fab5e1

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/background/BackgroundTaskSingleton.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ export default class BackgroundTaskSingleton {
2626
});
2727
}
2828

29-
public async start(): Promise<void> {
29+
public async start(toast: (msg: string) => void): Promise<void> {
3030
return new Promise<void>((resolve) => {
3131
this.isRunning().then(async (v) => {
3232
if (!v) {
33-
this.node.start('123', (msg: string) => console.log(msg));
33+
this.node.start('123', toast);
3434
await Heartbeat.startService();
3535
}
3636
resolve();

src/tabs/home/BackgroundTaskSwitch.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useEffect, useState } from 'react';
2-
import { View } from 'react-native';
2+
import { View, ToastAndroid } from 'react-native';
33
import SwitchToggle from 'react-native-switch-toggle';
44

55
import BackgroundTaskSingleton from '../../background/BackgroundTaskSingleton';
@@ -11,7 +11,9 @@ async function toggleSwitch(
1111
currentValue: boolean
1212
) {
1313
if (!currentValue) {
14-
await BackgroundTaskSingleton.instance.start();
14+
await BackgroundTaskSingleton.instance.start((msg: string) => {
15+
ToastAndroid.show(msg, ToastAndroid.SHORT);
16+
});
1517
} else {
1618
await BackgroundTaskSingleton.instance.stop();
1719
}

0 commit comments

Comments
 (0)