Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-context-execute

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-context-execute

Execute JS code in React Native's context even when RN is inactive (eg. app in background).

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

react-native-context-execute

Execute JS code in React Native's context even when RN is inactive (eg. app in background).

In Android, where background services are indispensable, keeping RN in sync can be hard since RN doesn't stay active in background. Currently, Android-only.

A tiny library which registers a JavascriptModule in RN's JavascriptModuleRegistry and makes Catalyst (Bridge) run it.

Before using this, please note that HeadlessJS is another good way to go.

Getting started

$ npm install react-native-context-execute --save

Mostly automatic installation

$ rnpm link react-native-context-execute

Manual installation

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

Usage

In your Java side, grab hold of the ReactApplicationContext and do,

WritableMap payload = Arguments.createMap();
payload.putString("some_key", "some_value");

new ReactContextExecutor(reactApplicationContext).execute("some_other_key", payload);

In JS side,

import { ContextExecute } from 'react-native-context-execute';

ContextExecute((op, data) => {
    // Do your thing
});

Keywords

FAQs

Package last updated on 21 Feb 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc