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

Commit 7825e11

Browse files
author
18829029633
committed
验证修改
1 parent f9033b2 commit 7825e11

File tree

8 files changed

+15
-181
lines changed

8 files changed

+15
-181
lines changed

harmony/sensors.har

-21 Bytes
Binary file not shown.

harmony/sensors/oh-package.json5

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
{
22
"name": "rnoh-sensors",
33
"version": "1.0.0",
4-
devDependencies: {
4+
dependencies: {
55
rnoh: 'file:../rnoh',
66
},
77
"main": "Index.ets",
88
"author": "",
9-
"license": "Apache-2.0",
10-
"dependencies": {}
9+
"license": "Apache-2.0"
1110
}

package.json

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
"semantic-release": "semantic-release",
1313
"travis-deploy-once": "travis-deploy-once"
1414
},
15-
"main": "index.js",
16-
"types": "index.d.ts",
15+
"main": "src/index.js",
16+
"types": "src/index.d.ts",
1717
"repository": "git@github.com:react-native-sensors/react-native-sensors.git",
1818
"homepage": "https://github.com/react-native-sensors/react-native-sensors",
1919
"keywords": [
@@ -74,14 +74,9 @@
7474
},
7575
"files": [
7676
"/RNSensors.podspec",
77-
"/src/*.js",
78-
"/index.*",
79-
"/android/",
80-
"/ios/",
81-
"/windows/",
77+
"/src/",
78+
"/harmony/",
8279
"/LICENSE",
83-
"/README.md",
84-
"/scripts/",
85-
"/website/"
80+
"/README.md"
8681
]
8782
}
File renamed without changes.
File renamed without changes.

index.js renamed to src/index.js

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import React from "react";
2-
import RTNSensors from "./NativeSensors";
31
import { DeviceEventEmitter } from "react-native";
42
import { Observable } from "rxjs";
53
import { publish, refCount } from "rxjs/operators";
@@ -13,13 +11,13 @@ const listenerKeys = new Map([
1311
["orientation", "orientationClick"],
1412
["gravity", "gravityClick"],
1513
]);
16-
const SensorType = {
14+
export const SensorTypes = {
1715
accelerometer: "accelerometer",
18-
gyroscope: "accelerometer",
19-
magnetometer: "accelerometer",
20-
barometer: "accelerometer",
21-
orientation: "accelerometer",
22-
gravity: "accelerometer",
16+
gyroscope: "gyroscope",
17+
magnetometer: "magnetometer",
18+
barometer: "barometer",
19+
orientation: "orientation",
20+
gravity: "gravity",
2321
};
2422

2523
const eventEmitterSubscription = new Map([
@@ -34,18 +32,14 @@ const eventEmitterSubscription = new Map([
3432
function createSensorObservable(sensorType) {
3533
return Observable.create(function subscribe(observer) {
3634
this.isSensorAvailable = false;
37-
if (eventEmitterSubscription.get(sensorType)) {
38-
eventEmitterSubscription.get(sensorType).remove();
39-
RTNSensors.off(sensorType);
40-
}
4135
this.unsubscribeCallback = () => {
4236
if (!this.isSensorAvailable) return;
4337
if (eventEmitterSubscription.get(sensorType)) eventEmitterSubscription.get(sensorType).remove();
4438
RTNSensors.off(sensorType);
4539
RTNSensors.setUpdateInterval(sensorType, 0);
4640
RTNSensors.setLogLevel(sensorType, 0);
4741
};
48-
RTNSensors.isAvailable(SensorType).then((res) => {
42+
RTNSensors.isAvailable(sensorType).then((res) => {
4943
this.isSensorAvailable = true;
5044
if (!res) {
5145
observer.error(`Sensors${sensorType} is not available`);
@@ -81,7 +75,7 @@ function createSensorObservable(sensorType) {
8175
}
8276
});
8377
return this.unsubscribeCallback;
84-
}).pipe(makeSingleton);
78+
}).pipe(makeSingleton());
8579
}
8680
function makeSingleton() {
8781
return (source) => source.pipe(publish(), refCount());

src/rnsensors.js

Lines changed: 0 additions & 57 deletions
This file was deleted.

src/sensors.js

Lines changed: 0 additions & 97 deletions
This file was deleted.

0 commit comments

Comments
 (0)