npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-terra-rt-react

v0.2.2

Published

test

Downloads

26

Readme

react-native-terra-rt-react

React Native bridge for Terra Realtime mobile SDKs

Installation

npm install react-native-terra-rt-react

Usage

To begin, please set up the environment as instructed by TerraRTiOS and TerraRTAndroid.

The functionalities form these SDKs have been bridged over so you may call them from react native.

Initialising TerraRT

This can be done using

initTerra(
  devId: String,
  referenceId?: String
): Promise<SuccessMessage>

Initialising a connection

initConnection(token: String): Promise<SuccessMessage>

Getting the UserId

getUserId(): Promise<GetUserId>

Start scanning for a device

On Android, you may use

startDeviceScan(
  connections: Connections,
  useCache: Boolean = false,
  showWidgetIfCacheNotFound: Boolean = false
): Promise<SuccessMessage> 

On iOS, the native view is bridged over to React Native as a component. You can get it as:

const BLWidget = requireNativeComponent('BLWidget');

And you may use it as a component:

<SafeAreaView style={styles.container}>
    {Platform.OS === 'ios' && displayWidget && (
    <BLWidget
        withCache={false}
        onSuccessfulConnection={_onSuccessfulConnection} // Function that is called when connection established
    />
    )}
</SafeAreaView>

In the case, it is displayed, it will automatically remove itself from view whe _onSuccessfulConnection is called.

Start streaming

startRealtime(
  connections: Connections,
  dataTypes: Array<DataTypes>,
  token: String | null = null
): Promise<SuccessMessage>

In the case you wish to receive data in the app, this function also updates the app in an event listener. You may receive updates by listening for "Update" events:

const eventEmitter = new NativeEventEmitter(NativeModules.UpdateHandler);
    eventEmitter.addListener('Update', (event: Update) => {
        // Update view with event
    });

Stop streaming

stopRealtime(
  connections: Connections
): Promise<SuccessMessage>

Disconnecting from device

disconnect(connections: Connections): Promise<SuccessMessage>

Connecting to WatchOS (iOS ONLY)

connectWithWatchOS(): Promise<SuccessMessage>

In the case you wish to use this, you will need to create a companion app for the current react native app in native Swift/ObjC. This is because react-native has yet to support WatchOS developement. TerraRTiOS supports WatchOS integration directly.

Types

Types used above can be seen here.

enum Connections {
  ANT = 'ANT',
  BLE = 'BLE',
  WEAR_OS = 'WEAR_OS',
  WATCH_OS = 'WATCH_OS',
  ANDROID = 'ANDROID',
  ALL_DEVICES = 'ALL_DEVICES',
  APPLE = 'APPLE',
}

enum DataTypes {
  HEART_RATE = 'HEART_RATE',
  ECG = 'ECG',
  STEPS = 'STEPS',
  HRV = 'HRV',
  CALORIES = 'CALORIES',
  LOCATION = 'LOCATION',
  DISTANCE = 'DISTANCE',
  ACTIVITY = 'ACTIVITY',
  ACCELERATION = 'ACCELERATION',
  GYROSCOPE = 'GYROSCOPE',
  FLOORS_CLIMBED = 'FLOORS_CLIMBED',
  STEPS_CADENCE = 'STEPS_CADENCE',
  SPEED = 'SPEED',
  POWER = 'POWER',
  BIKE_CADENCE = 'BIKE_CADENCE',
  MET = 'MET',
  RR_INTERVAL = 'RR_INTERVAL',
}

type GetUserId = {
  success: Boolean;
  userId: String | null;
};

type SuccessMessage = {
  success: Boolean;
  error: String | null;
};

type Update = {
  ts: String | null;
  val: number | null;
  type: String | null;
  d: Array<number> | null;
};

Example

A very simple example project was generated here. This is used as internal testing and may providing a starting point for you if needed. Please fill in the config file with credentials to start.

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library