id | title |
---|---|
Changelog |
Changelog |
We added Typescript typings.
We added experimental support for the Barometer, it can be used like this:
import { barometer } from "react-native-sensors";
const subscription = barometer.subscribe(({ pressure }) => console.log({ pressure }));
Please help us improve the quality by using this sensor and giving feedback!
In this release we defined a whole new API that does not rely on promises anymore. To migrate please also update RxJS to a version greater than 6.
- import { Accelerometer, Gyroscope } from "react-native-sensors";
+ import {
+ accelerometer, // direct access to the observables
+ gyroscope,
+ setUpdateIntervalForType, // set update interval globally
+ SensorTypes
+ } from "react-native-sensors";
+ // update to RxJS >= 6
+ import { map, filter } from "rxjs/operators";
- let accelerationObservable = null;
- new Accelerometer({
- updateInterval: 400 // defaults to 100ms
- })
- .then(observable => {
- accelerationObservable = observable;
// Normal RxJS functions
- accelerationObservable
- .map(({ x, y, z }) => x + y + z)
- .filter(speed => speed > 20)
+ const subscription = accelerometer.pipe(
+ map(({ x, y, z }) => x + y + z)
+ filter(speed => speed > 20)
+ )
- .subscribe(speed => console.log(`You moved your phone with ${speed}`));
+ .subscribe(speed => console.log(`You moved your phone with ${speed}`), error => {
+ console.log("The sensor is not available");
+ });
- })
- .catch(error => {
- console.log("The sensor is not available");
- });
setTimeout(() => {
- accelerationObservable.stop();
+ subscription.unsubscribe();
}, 1000);
We dropped support for the decorator syntax as it added a lot of testing surface.
Please use libraries like recompose with componentFromStream
to fill the gap. If you need help with this feel free to open an issue and we will provide more context and guidance.
- Add Semantic Release
- Magnetometer support
- Add linking failure message: If you forget to link the native dependencies you now get
"Native modules for sensors not available. Did react-native link run successfully?"
as an error - Fix sensor availability checks
- Fix startup API
- BREAKING: removed windows support We had to remove the windows support as there was no one maintaining it. If you have interest in using this library on a windows phone, please leave an issue. We would be very happy to revert this commit and get windows up to speed again.
- BREAKING: Check if sensor is supported You can now check if a sensor is available on the device. This changed the API, therefore it's a breaking change. Special thanks to @dabit1 for introducing this much needed functionality.
- Magnetometer support
- Add linking failure message: If you forget to link the native dependencies you now get
"Native modules for sensors not available. Did react-native link run successfully?"
as an error - Fix sensor availability checks
- Fix startup API
- BREAKING: removed windows support We had to remove the windows support as there was no one maintaining it. If you have interest in using this library on a windows phone, please leave an issue. We would be very happy to revert this commit and get windows up to speed again.
- BREAKING: Check if sensor is supported You can now check if a sensor is available on the device. This changed the API, therefore it's a breaking change. Special thanks to @dabit1 for introducing this much needed functionality.
- Restore the original api <- fix for unintentional change of our API by @epeli
- Move from
React.PropTypes
toprop-types
- Throw error instead of crash if a certain sensor is missing <- This caused an unintenional change in our API