├── LICENSE ├── README.md ├── example ├── .buckconfig ├── .flowconfig ├── .gitattributes ├── .gitignore ├── .watchmanconfig ├── App.js ├── Elsewhere.js ├── __tests__ │ └── App-test.js ├── android │ ├── app │ │ ├── BUCK │ │ ├── build.gradle │ │ ├── build_defs.bzl │ │ ├── proguard-rules.pro │ │ └── src │ │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ └── com │ │ │ │ └── elsewhere │ │ │ │ ├── MainActivity.java │ │ │ │ └── MainApplication.java │ │ │ └── res │ │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ └── values │ │ │ ├── strings.xml │ │ │ └── styles.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ ├── keystores │ │ ├── BUCK │ │ └── debug.keystore.properties │ └── settings.gradle ├── app.json ├── babel.config.js ├── index.js ├── ios │ ├── elsewhere-tvOS │ │ └── Info.plist │ ├── elsewhere-tvOSTests │ │ └── Info.plist │ ├── elsewhere.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ ├── elsewhere-tvOS.xcscheme │ │ │ └── elsewhere.xcscheme │ ├── elsewhere │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Base.lproj │ │ │ └── LaunchScreen.xib │ │ ├── Images.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ │ └── Contents.json │ │ ├── Info.plist │ │ └── main.m │ └── elsewhereTests │ │ ├── Info.plist │ │ └── elsewhereTests.m ├── metro.config.js ├── package.json └── yarn.lock ├── index.js ├── package.json └── yarn.lock /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Alexander Thomas 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 🚨 Deprecation Notice 2 | The `` component relies upon the `toString()` method to delegate native functions to a ``, which is [not possible to achieve in conjunction with the Hermes engine](https://github.com/facebook/hermes/issues/114). 3 | 4 | Developers are urged to migrate into [nodejs-mobile-react-native-bridge](https://github.com/cawfree/nodejs-mobile-react-native-bridge). 5 | 6 | # react-native-elsewhere 7 | Ridiculously simple React Native thread unblocking. 8 | 9 | ## 🚀 Getting Started 10 | Using [npm](https://www.npmjs.com/package/@cawfree/react-native-elsewhere): 11 | ```shell 12 | npm install --save @cawfree/react-native-elsewhere 13 | ``` 14 | Using [yarn](https://www.npmjs.com/package/@cawfree/react-native-elsewhere): 15 | ```shell 16 | yarn add @cawfree/react-native-elsewhere 17 | ``` 18 | Yeah, no linking. 👍 19 | 20 | ## ⚙ How does it work? 21 | By delegating stateless JavaScript computation to a [``](https://facebook.github.io/react-native/docs/webview), your app can maintain responsive whilst you crunch through heavy computation in the background. 22 | 23 | ```javascript 24 | import React, {Component} from 'react'; 25 | import {WebView, Button, Platform, StyleSheet, Text, View, Alert} from 'react-native'; 26 | 27 | import Elsewhere from '@cawfree/react-native-elsewhere'; 28 | 29 | // https://gist.github.com/sqren/5083d73f184acae0c5b7 30 | function doSomethingIntense(postMessage, { source }) { 31 | const now = new Date(); 32 | let result = 0; 33 | for (var i = Math.pow(10, 7); i >= 0; i--) { 34 | result += Math.atan(i) * Math.tan(i); 35 | }; 36 | postMessage({ 37 | source, 38 | result, 39 | dt: new Date().getTime() - now.getTime(), 40 | }); 41 | } 42 | 43 | type Props = {}; 44 | export default class App extends Component { 45 | state = { 46 | postMessage: () => null, 47 | } 48 | render() { 49 | const { 50 | postMessage, 51 | } = this.state; 52 | return ( 53 | 54 | Alert.alert(JSON.stringify(data))} 58 | onPostMessage={(postMessage) => { 59 | this.setState({ 60 | postMessage, 61 | }); 62 | }} 63 | /> 64 | Welcome to React Native! 65 | To get started, open the debug menu and enable the performance monitor so we can watch the JS frame rate. 66 | It should read a steady 60fps. ⏰ 67 | {'🤓'} 68 | Tap the Button below to watch your frame rate plummet! 📉 69 | 74 |