react-native-vitals

2.0.1 • Public • Published

react-native-vitals

React Native package that provides memory/storage usage info of a device.

Usage

import Vitals from 'react-native-vitals';
 
Vitals.getMemory(memory => {
  var {
    appUsed,
    systemTotal,
    systemFree,
    systemUsed
  } = memory;
});
 
Vitals.getStorage(storage => {
  var {
    total,
    free,
    used
  } = storage;
});
 
Vitals.addLowMemoryListener(memory => {
  console.log('Low memory warning triggered');
  var {
    appUsed,
    systemTotal,
    systemFree,
    systemUsed
  } = memory;
})

Getting started

$ npm install react-native-vitals --save

Mostly automatic installation

$ react-native link react-native-vitals

Manual installation

iOS

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modulesreact-native-vitals and add RNVitals.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libRNVitals.a to your project's Build PhasesLink Binary With Libraries
  4. Run your project (Cmd+R)

iOS (using CocoaPods)

Alternatively, you can use CocoaPods to manage your native dependencies, just add this inside your Podfile:

  pod 'react-native-vitals', :path => '../node_modules/react-native-vitals'

After adding this, you need to run pod install inside the ios-folder of your RN application.

Android

  1. Open up android/app/src/main/java/[...]/MainActivity.java
  • Add import com.robinpowered.react.vitals.RNVitalsPackage; to the imports at the top of the file
  • Add new RNVitalsPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ':react-native-vitals'
    project(':react-native-vitals').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-vitals/android')
    
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      compile project(':react-native-vitals')
    

Package Sidebar

Install

npm i react-native-vitals

Weekly Downloads

2,678

Version

2.0.1

License

MIT

Unpacked Size

35.7 kB

Total Files

17

Last publish

Collaborators

  • atticoos