├── .babelrc ├── .gitignore ├── .npmignore ├── .travis.yml ├── LICENSE ├── README.md ├── examples └── SimpleExample │ ├── .babelrc │ ├── .buckconfig │ ├── .flowconfig │ ├── .gitattributes │ ├── .gitignore │ ├── .watchmanconfig │ ├── __tests__ │ ├── index.android.js │ └── index.ios.js │ ├── android │ ├── app │ │ ├── BUCK │ │ ├── build.gradle │ │ ├── proguard-rules.pro │ │ └── src │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ └── com │ │ │ │ └── simpleexample │ │ │ │ ├── MainActivity.java │ │ │ │ └── MainApplication.java │ │ │ └── res │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.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 │ ├── index.android.js │ ├── index.ios.js │ ├── ios │ ├── SimpleExample-tvOS │ │ └── Info.plist │ ├── SimpleExample-tvOSTests │ │ └── Info.plist │ ├── SimpleExample.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ ├── SimpleExample-tvOS.xcscheme │ │ │ └── SimpleExample.xcscheme │ ├── SimpleExample │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Base.lproj │ │ │ └── LaunchScreen.xib │ │ ├── Images.xcassets │ │ │ └── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ ├── Info.plist │ │ └── main.m │ └── SimpleExampleTests │ │ ├── Info.plist │ │ └── SimpleExampleTests.m │ ├── package.json │ └── yarn.lock ├── jest.config.json ├── package.json ├── src ├── index.ts ├── jobHandlerModifiers │ ├── index.ts │ └── limitJobRuns.ts ├── jobPersistence.ts ├── jobRunner.ts ├── jobSubscriptions.ts ├── jobTypes.ts ├── persistentJobClient.ts ├── streamModifiers │ ├── index.ts │ ├── retryStream │ │ ├── index.ts │ │ ├── noRetries.ts │ │ └── withBackoff.ts │ ├── runWhenOnline.ts │ └── types.ts └── utils │ └── transformAsyncStorage.ts ├── tests ├── asyncStorage.ts ├── jobHandlerModifiers │ └── limitJobRuns.spec.ts ├── jobStorageState.ts ├── persistentJobClient.spec.ts ├── preprocessor.js └── subjectModifiers │ ├── retryStream │ └── withBackoff.spec.ts │ └── runWhenOnline.spec.ts ├── tsconfig.json └── yarn.lock /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["es2015", "es2017", "stage-2", "react"] 3 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | /coverage 3 | /lib 4 | TODO -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .gitignore 3 | .babelrc 4 | tsconfig.json 5 | test 6 | examples 7 | .travis.yml -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "7" 4 | branches: 5 | only: 6 | - master 7 | script: 8 | - npm run test -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 GabiNir 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 | # react-native-persistent-job 2 | 3 | [![NPM version](https://img.shields.io/npm/v/react-native-persistent-job.svg)](https://www.npmjs.com/package/react-native-persistent-job) 4 | [![build status](https://travis-ci.org/Gabrn/react-native-persistent-job.svg?branch=master)](https://travis-ci.org/Gabrn/react-native-persistent-job) 5 | * Run parametized asynchronous functions (called `jobs`) that will re-run in cases of failure, connection loss, application crash or user forced shutdowns. 6 | * Runs on both android and iOS. 7 | 8 | ## Why? 9 | 10 | When you develop an application you usually focus on the 'happy flow', where everything runs smoothly, the user has perfect connection, he only leaves the app through the exit button, the app never crashes and your backend or any of the services you use never fail. 11 | Well... it is not usually like that. 12 | Things will fail and might leave your application in an unstable state. 13 | This repository aims to help deal with that. 14 | 15 | ## Installation 16 | 17 | Install package from npm 18 | 19 | ```sh 20 | npm install --save react-native-persistent-job 21 | ``` 22 | 23 | 24 | ## Usage 25 | 26 | There are 2 main apis. One for initialization, registering job types and applying modifiers (`initializeStore`) and one for running jobs (`createJob`). 27 | 28 | ### `initializeStore` 29 | `initializeStore` is used to set up options & run stored jobs. 30 | As soon as `initializeStore` is called the stored jobs that did not finish execution run. 31 | To run any kind of persistent job you must call `initializeStore` first. 32 | 33 | Arguments: 34 | * `storeName?: string` - optional store name that identifies your instance when you call createJob 35 | * `jobHandlers: Array<{jobType: string, handleFunction: (...args: any) => Promise}>` - an array of job type (the key that identifies the job) and an handle function to run when the job type is called 36 | * `modifyJobStream?: Rx.Observable => RxObservable` - Modifies the stream that runs the jobs (more on that later in the readme) 37 | * `modifyRetryStream?: Rx.Observable => RxObservable` - Modifies the stream that retries the jobs (more on that later in the readme) 38 | * `concurrencyLimit?: number` - Limit the number of jobs that can run concurrently, other jobs will have to wait until the running jobs finish before they can run. 39 | 40 | ### `createJob` 41 | `createJob` is used to run the jobs, it accepts the job type as an argument and returns the function of that job type wrapped with persistent-job functionality. 42 | For example if I want to run a function `(a, b, c) => console.log(a, b, c)` that has a jobType `console` I will run it like this: `persistentJob.store().createJob('console')('valueForA', 'valueForB', 'valueForC')` 43 | 44 | Arguments: 45 | * `jobType: string` - the job type for the job you want to run that you registered beforehand in `initializeStore` with the `jobHandlers` param 46 | * `...args: any[]` - the args that the function accepts 47 | 48 | ### example for `initializeStore` and `createJob` 49 | 50 | ```js 51 | import persistentJob from 'react-native-persistent-job' 52 | 53 | const logIt = (a, b, c) => console.log(a, b, c) 54 | 55 | await persistentJob.initializeStore({ 56 | jobHandlers: [{jobType: 'logIt', handleFunction: logIt}] 57 | }) 58 | 59 | const persistentLogIt = persistentJob.store().createJob('logIt') 60 | persistentLogIt('valueForA', 'valueForB', 'valueForC') 61 | persistentLogIt('AnotherValueForA', 'AnotherValueForB', 'AnotherValueForC') 62 | ``` 63 | 64 | ## Job & Retry streams 65 | The jobs run on a stream that can be modified using rx. There are some built-in modifiers which can be used to modify the stream. 66 | 67 | ### `runWhenOnline` 68 | Will only run the jobs once the device is connected to the internet. 69 | 70 | * example 71 | ```js 72 | import persistentJob, {streamModifiers} from 'react-native-persistent-job' 73 | 74 | const logIt = (a, b, c) => console.log(a, b, c) 75 | 76 | await persistentJob.initializeStore({ 77 | storeName: 'online-jobs', 78 | jobHandlers: [{jobType: 'logIt', handleFunction: logIt}] 79 | modifyJobStream: streamModifiers.runWhenOnline 80 | }) 81 | 82 | const persistentLogIt = persistentJob.store('online-jobs').createJob('logIt') 83 | persistentLogIt('valueForA', 'valueForB', 'valueForC') 84 | ``` 85 | 86 | ### `withBackoff` 87 | Will run failed jobs with delay based on a backoff method (right now either exponential or fibonacci) 88 | 89 | * Api: 90 | ```js 91 | streamModifiers.retryStream.withBackoff.{exponential / fibonacci}(initialWaitTime: number, maxWaitTime?: number) 92 | ``` 93 | 94 | * Example: 95 | 96 | ```js 97 | import persistentJob, {streamModifiers} from 'react-native-persistent-job' 98 | 99 | const failureOfAJob = (msg) => { 100 | console.log(msg) 101 | throw 'I failed' 102 | } 103 | 104 | const failingJobsStore = await persistentJob.initializeStore({ 105 | storeName: 'failing-jobs', 106 | jobHandlers: [{jobType: 'failureOfAJob', handleFunction: failureOfAJob}] 107 | modifyRetryStream: streamModifiers.retryStream.withBackoff.exponential(10, 50) 108 | }) 109 | 110 | const persistentFailureOfAJob = failingJobsStore.createJob('failureOfAJob') 111 | persistentFailureOfAJob('I will fail while running') 112 | ``` 113 | 114 | ## Stateful & stateless jobs 115 | Usually you will want to use stateless jobs. 116 | Sometimes however, it is more convenient for a job to have a state, then whenever it runs after a failure it will remember the last state it was at. 117 | To do that your function will have to have a prefix with 2 arguments `currentState` and `updateState`. 118 | Here is an example with both a stateless and a stateful job: 119 | ```js 120 | const statelessJob = async (name) => { 121 | for (let i = 0; i < 10; i++) { 122 | console.log('Hello name', i) 123 | } 124 | } 125 | 126 | const statefulJob = (currentState, updateState) => async (name) => { 127 | const start = currentState || 0 128 | for (let i = start; i < 10; i++) { 129 | console.log('Hello name', i) 130 | await updateState(i) 131 | } 132 | } 133 | 134 | await persistentJob.initializeStore({ 135 | storeName: 'stateless-stateful', 136 | jobHandlers: [ 137 | {jobType: 'stateless', handleFunction: statelessJob}, 138 | {jobType: 'stateful', handleFunction: statefulJob, isStateful: true} 139 | ] 140 | }) 141 | 142 | const persistentStatelessJob = persistentJob.store('stateless-stateful').createJob('stateless') 143 | const persistentStatefulJob = persistentJob.store('stateless-stateful').createJob('stateful') 144 | persistentStatelessJob('john') 145 | persistentStatefulJob('mary') 146 | ``` 147 | 148 | ## jobHandlerModifiers 149 | ### `limitJobRuns` 150 | Limits the number of possible failures a particular job can have before it is terminated 151 | * example 152 | ```js 153 | import persistentJob, {jobHandlerModifiers} from 'react-native-persistent-job' 154 | 155 | const logIt = (a, b, c) => console.log(a, b, c) 156 | 157 | await persistentJob.initializeStore({ 158 | jobHandlers: [ 159 | jobHandlerModifiers.limitJobRuns(3)({jobType: 'logIt', handleFunction: logIt}) // here we modify the handler to run failing jobs only 3 times max. 160 | ] 161 | }) 162 | 163 | const persistentLogIt = persistentJob.store().createJob('logIt') 164 | persistentLogIt('valueForA', 'valueForB', 'valueForC') // will only run 3 times 165 | ``` 166 | 167 | ## Subscriptions 168 | Many times when async operations are running it's good to give some sort of indication for better user experience. 169 | Like for example if we made an http request that fetches some data for the user we might want to show a spinner that indicated the request is still active. 170 | The most convenient way to do that is with subscriptions (calling the state management library from within the jobs is also an option but not as convenient). 171 | To subscribe to a job we must first give the job a `topic`. Like this: 172 | ```js 173 | const jobWithTopic = persistentJob.store().createJob('myJob', 'some_topic') 174 | jobWithTopic() 175 | ``` 176 | 177 | Then we can subscribe to the topic like this (it is also possible to subscribe to a topic before we run the job, the first value we will receive is JOB_NOT_FOUND though, after that we will receive the rest of the states): 178 | ```js 179 | // subscribing the job 180 | const unsubscribe = persistentJob.store().subscribe('some_topic', (jobTopicOutput) => { 181 | console.log('do something') 182 | }) 183 | 184 | // to unsubscribe 185 | unsubscribe() 186 | ``` 187 | 188 | * Subsciptions will also work after an application crash, meaning that if we subscribe to a job that failed in the last application run the subscription will still get data from it. 189 | 190 | * The subscription function returns a function to unsubscribe 191 | 192 | * When the subscription function is called it is passed an object of the following structure: 193 | ```js 194 | {jobState: 'JOB_STARTED' | 'JOB_DONE' | 'JOB_NOT_FOUND' | 'JOB_INTERMEDIATE' | 'JOB_FAILED', value?: any} 195 | ``` 196 | Each jobState meaning is displayed in the `console.log` functions in this example: 197 | 198 | ```js 199 | const unsubscribe = persistentJob.store().subscribe('some_topic', (jobTopicOutput) => { 200 | if (jobTopicOutput.jobState === 'JOB_STARTED') console.log('job is just starting') 201 | if (jobTopicOutput.jobState === 'JOB_DONE') { 202 | console.log('job finished in this current application run') 203 | console.log(`This is the value the job finished with: ${jobTopicOutput.value}`) 204 | } 205 | if (jobTopicOutput.jobState === 'JOB_NOT_FOUND') console.log('job finished in some other application run or was never started') 206 | if (jobTopicOutput.jobState === 'JOB_INTERMEDIATE') { 207 | console.log('Only stateful jobs have intermediate state, it also has a value which is the current state of the stateful job') 208 | 209 | console.log(`This is the intermediate state value: ${jobTopicOutput.value}`) 210 | } 211 | 212 | if (jobTopicOutput.jobState === 'JOB_FAILED') { 213 | console.log('Job failed in this application run, it might restart soon though') 214 | 215 | console.log(`This is the error ${jobTopicOutput.value}`) 216 | } 217 | }) 218 | ``` 219 | 220 | 221 | -------------------------------------------------------------------------------- /examples/SimpleExample/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["react-native"] 3 | } 4 | -------------------------------------------------------------------------------- /examples/SimpleExample/.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /examples/SimpleExample/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | ; We fork some components by platform 3 | .*/*[.]android.js 4 | 5 | ; Ignore "BUCK" generated dirs 6 | /\.buckd/ 7 | 8 | ; Ignore unexpected extra "@providesModule" 9 | .*/node_modules/.*/node_modules/fbjs/.* 10 | 11 | ; Ignore duplicate module providers 12 | ; For RN Apps installed via npm, "Libraries" folder is inside 13 | ; "node_modules/react-native" but in the source repo it is in the root 14 | .*/Libraries/react-native/React.js 15 | .*/Libraries/react-native/ReactNative.js 16 | 17 | [include] 18 | 19 | [libs] 20 | node_modules/react-native/Libraries/react-native/react-native-interface.js 21 | node_modules/react-native/flow 22 | flow/ 23 | 24 | [options] 25 | emoji=true 26 | 27 | module.system=haste 28 | 29 | munge_underscores=true 30 | 31 | module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub' 32 | 33 | suppress_type=$FlowIssue 34 | suppress_type=$FlowFixMe 35 | suppress_type=$FixMe 36 | 37 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(4[0-9]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) 38 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(4[0-9]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ 39 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy 40 | suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError 41 | 42 | unsafe.enable_getters_and_setters=true 43 | 44 | [version] 45 | ^0.49.1 46 | -------------------------------------------------------------------------------- /examples/SimpleExample/.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | -------------------------------------------------------------------------------- /examples/SimpleExample/.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | project.xcworkspace 24 | 25 | # Android/IntelliJ 26 | # 27 | build/ 28 | .idea 29 | .gradle 30 | local.properties 31 | *.iml 32 | 33 | # node.js 34 | # 35 | node_modules/ 36 | npm-debug.log 37 | yarn-error.log 38 | 39 | # BUCK 40 | buck-out/ 41 | \.buckd/ 42 | *.keystore 43 | 44 | # fastlane 45 | # 46 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 47 | # screenshots whenever they are needed. 48 | # For more information about the recommended setup visit: 49 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 50 | 51 | fastlane/report.xml 52 | fastlane/Preview.html 53 | fastlane/screenshots 54 | -------------------------------------------------------------------------------- /examples/SimpleExample/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /examples/SimpleExample/__tests__/index.android.js: -------------------------------------------------------------------------------- 1 | import 'react-native'; 2 | import React from 'react'; 3 | import Index from '../index.android.js'; 4 | 5 | // Note: test renderer must be required after react-native. 6 | import renderer from 'react-test-renderer'; 7 | 8 | it('renders correctly', () => { 9 | const tree = renderer.create( 10 | 11 | ); 12 | }); 13 | -------------------------------------------------------------------------------- /examples/SimpleExample/__tests__/index.ios.js: -------------------------------------------------------------------------------- 1 | import 'react-native'; 2 | import React from 'react'; 3 | import Index from '../index.ios.js'; 4 | 5 | // Note: test renderer must be required after react-native. 6 | import renderer from 'react-test-renderer'; 7 | 8 | it('renders correctly', () => { 9 | const tree = renderer.create( 10 | 11 | ); 12 | }); 13 | -------------------------------------------------------------------------------- /examples/SimpleExample/android/app/BUCK: -------------------------------------------------------------------------------- 1 | # To learn about Buck see [Docs](https://buckbuild.com/). 2 | # To run your application with Buck: 3 | # - install Buck 4 | # - `npm start` - to start the packager 5 | # - `cd android` 6 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` 7 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck 8 | # - `buck install -r android/app` - compile, install and run application 9 | # 10 | 11 | lib_deps = [] 12 | 13 | for jarfile in glob(['libs/*.jar']): 14 | name = 'jars__' + jarfile[jarfile.rindex('/') + 1: jarfile.rindex('.jar')] 15 | lib_deps.append(':' + name) 16 | prebuilt_jar( 17 | name = name, 18 | binary_jar = jarfile, 19 | ) 20 | 21 | for aarfile in glob(['libs/*.aar']): 22 | name = 'aars__' + aarfile[aarfile.rindex('/') + 1: aarfile.rindex('.aar')] 23 | lib_deps.append(':' + name) 24 | android_prebuilt_aar( 25 | name = name, 26 | aar = aarfile, 27 | ) 28 | 29 | android_library( 30 | name = "all-libs", 31 | exported_deps = lib_deps, 32 | ) 33 | 34 | android_library( 35 | name = "app-code", 36 | srcs = glob([ 37 | "src/main/java/**/*.java", 38 | ]), 39 | deps = [ 40 | ":all-libs", 41 | ":build_config", 42 | ":res", 43 | ], 44 | ) 45 | 46 | android_build_config( 47 | name = "build_config", 48 | package = "com.simpleexample", 49 | ) 50 | 51 | android_resource( 52 | name = "res", 53 | package = "com.simpleexample", 54 | res = "src/main/res", 55 | ) 56 | 57 | android_binary( 58 | name = "app", 59 | keystore = "//android/keystores:debug", 60 | manifest = "src/main/AndroidManifest.xml", 61 | package_type = "debug", 62 | deps = [ 63 | ":app-code", 64 | ], 65 | ) 66 | -------------------------------------------------------------------------------- /examples/SimpleExample/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "com.android.application" 2 | 3 | import com.android.build.OutputFile 4 | 5 | /** 6 | * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets 7 | * and bundleReleaseJsAndAssets). 8 | * These basically call `react-native bundle` with the correct arguments during the Android build 9 | * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the 10 | * bundle directly from the development server. Below you can see all the possible configurations 11 | * and their defaults. If you decide to add a configuration block, make sure to add it before the 12 | * `apply from: "../../node_modules/react-native/react.gradle"` line. 13 | * 14 | * project.ext.react = [ 15 | * // the name of the generated asset file containing your JS bundle 16 | * bundleAssetName: "index.android.bundle", 17 | * 18 | * // the entry file for bundle generation 19 | * entryFile: "index.android.js", 20 | * 21 | * // whether to bundle JS and assets in debug mode 22 | * bundleInDebug: false, 23 | * 24 | * // whether to bundle JS and assets in release mode 25 | * bundleInRelease: true, 26 | * 27 | * // whether to bundle JS and assets in another build variant (if configured). 28 | * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants 29 | * // The configuration property can be in the following formats 30 | * // 'bundleIn${productFlavor}${buildType}' 31 | * // 'bundleIn${buildType}' 32 | * // bundleInFreeDebug: true, 33 | * // bundleInPaidRelease: true, 34 | * // bundleInBeta: true, 35 | * 36 | * // whether to disable dev mode in custom build variants (by default only disabled in release) 37 | * // for example: to disable dev mode in the staging build type (if configured) 38 | * devDisabledInStaging: true, 39 | * // The configuration property can be in the following formats 40 | * // 'devDisabledIn${productFlavor}${buildType}' 41 | * // 'devDisabledIn${buildType}' 42 | * 43 | * // the root of your project, i.e. where "package.json" lives 44 | * root: "../../", 45 | * 46 | * // where to put the JS bundle asset in debug mode 47 | * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", 48 | * 49 | * // where to put the JS bundle asset in release mode 50 | * jsBundleDirRelease: "$buildDir/intermediates/assets/release", 51 | * 52 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 53 | * // require('./image.png')), in debug mode 54 | * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", 55 | * 56 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 57 | * // require('./image.png')), in release mode 58 | * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", 59 | * 60 | * // by default the gradle tasks are skipped if none of the JS files or assets change; this means 61 | * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to 62 | * // date; if you have any other folders that you want to ignore for performance reasons (gradle 63 | * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ 64 | * // for example, you might want to remove it from here. 65 | * inputExcludes: ["android/**", "ios/**"], 66 | * 67 | * // override which node gets called and with what additional arguments 68 | * nodeExecutableAndArgs: ["node"], 69 | * 70 | * // supply additional arguments to the packager 71 | * extraPackagerArgs: [] 72 | * ] 73 | */ 74 | 75 | apply from: "../../node_modules/react-native/react.gradle" 76 | 77 | /** 78 | * Set this to true to create two separate APKs instead of one: 79 | * - An APK that only works on ARM devices 80 | * - An APK that only works on x86 devices 81 | * The advantage is the size of the APK is reduced by about 4MB. 82 | * Upload all the APKs to the Play Store and people will download 83 | * the correct one based on the CPU architecture of their device. 84 | */ 85 | def enableSeparateBuildPerCPUArchitecture = false 86 | 87 | /** 88 | * Run Proguard to shrink the Java bytecode in release builds. 89 | */ 90 | def enableProguardInReleaseBuilds = false 91 | 92 | android { 93 | compileSdkVersion 23 94 | buildToolsVersion "23.0.1" 95 | 96 | defaultConfig { 97 | applicationId "com.simpleexample" 98 | minSdkVersion 16 99 | targetSdkVersion 22 100 | versionCode 1 101 | versionName "1.0" 102 | ndk { 103 | abiFilters "armeabi-v7a", "x86" 104 | } 105 | } 106 | splits { 107 | abi { 108 | reset() 109 | enable enableSeparateBuildPerCPUArchitecture 110 | universalApk false // If true, also generate a universal APK 111 | include "armeabi-v7a", "x86" 112 | } 113 | } 114 | buildTypes { 115 | release { 116 | minifyEnabled enableProguardInReleaseBuilds 117 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 118 | } 119 | } 120 | // applicationVariants are e.g. debug, release 121 | applicationVariants.all { variant -> 122 | variant.outputs.each { output -> 123 | // For each separate APK per architecture, set a unique version code as described here: 124 | // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits 125 | def versionCodes = ["armeabi-v7a":1, "x86":2] 126 | def abi = output.getFilter(OutputFile.ABI) 127 | if (abi != null) { // null for the universal-debug, universal-release variants 128 | output.versionCodeOverride = 129 | versionCodes.get(abi) * 1048576 + defaultConfig.versionCode 130 | } 131 | } 132 | } 133 | } 134 | 135 | dependencies { 136 | compile fileTree(dir: "libs", include: ["*.jar"]) 137 | compile "com.android.support:appcompat-v7:23.0.1" 138 | compile "com.facebook.react:react-native:+" // From node_modules 139 | } 140 | 141 | // Run this once to be able to run the application with BUCK 142 | // puts all compile dependencies into folder libs for BUCK to use 143 | task copyDownloadableDepsToLibs(type: Copy) { 144 | from configurations.compile 145 | into 'libs' 146 | } 147 | -------------------------------------------------------------------------------- /examples/SimpleExample/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Disabling obfuscation is useful if you collect stack traces from production crashes 20 | # (unless you are using a system that supports de-obfuscate the stack traces). 21 | -dontobfuscate 22 | 23 | # React Native 24 | 25 | # Keep our interfaces so they can be used by other ProGuard rules. 26 | # See http://sourceforge.net/p/proguard/bugs/466/ 27 | -keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip 28 | -keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters 29 | -keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip 30 | 31 | # Do not strip any method/class that is annotated with @DoNotStrip 32 | -keep @com.facebook.proguard.annotations.DoNotStrip class * 33 | -keep @com.facebook.common.internal.DoNotStrip class * 34 | -keepclassmembers class * { 35 | @com.facebook.proguard.annotations.DoNotStrip *; 36 | @com.facebook.common.internal.DoNotStrip *; 37 | } 38 | 39 | -keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * { 40 | void set*(***); 41 | *** get*(); 42 | } 43 | 44 | -keep class * extends com.facebook.react.bridge.JavaScriptModule { *; } 45 | -keep class * extends com.facebook.react.bridge.NativeModule { *; } 46 | -keepclassmembers,includedescriptorclasses class * { native ; } 47 | -keepclassmembers class * { @com.facebook.react.uimanager.UIProp ; } 48 | -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactProp ; } 49 | -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactPropGroup ; } 50 | 51 | -dontwarn com.facebook.react.** 52 | 53 | # TextLayoutBuilder uses a non-public Android constructor within StaticLayout. 54 | # See libs/proxy/src/main/java/com/facebook/fbui/textlayoutbuilder/proxy for details. 55 | -dontwarn android.text.StaticLayout 56 | 57 | # okhttp 58 | 59 | -keepattributes Signature 60 | -keepattributes *Annotation* 61 | -keep class okhttp3.** { *; } 62 | -keep interface okhttp3.** { *; } 63 | -dontwarn okhttp3.** 64 | 65 | # okio 66 | 67 | -keep class sun.misc.Unsafe { *; } 68 | -dontwarn java.nio.file.* 69 | -dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement 70 | -dontwarn okio.** 71 | -------------------------------------------------------------------------------- /examples/SimpleExample/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | 13 | 14 | 20 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /examples/SimpleExample/android/app/src/main/java/com/simpleexample/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.simpleexample; 2 | 3 | import com.facebook.react.ReactActivity; 4 | 5 | public class MainActivity extends ReactActivity { 6 | 7 | /** 8 | * Returns the name of the main component registered from JavaScript. 9 | * This is used to schedule rendering of the component. 10 | */ 11 | @Override 12 | protected String getMainComponentName() { 13 | return "SimpleExample"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /examples/SimpleExample/android/app/src/main/java/com/simpleexample/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.simpleexample; 2 | 3 | import android.app.Application; 4 | 5 | import com.facebook.react.ReactApplication; 6 | import com.facebook.react.ReactNativeHost; 7 | import com.facebook.react.ReactPackage; 8 | import com.facebook.react.shell.MainReactPackage; 9 | import com.facebook.soloader.SoLoader; 10 | 11 | import java.util.Arrays; 12 | import java.util.List; 13 | 14 | public class MainApplication extends Application implements ReactApplication { 15 | 16 | private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { 17 | @Override 18 | public boolean getUseDeveloperSupport() { 19 | return BuildConfig.DEBUG; 20 | } 21 | 22 | @Override 23 | protected List getPackages() { 24 | return Arrays.asList( 25 | new MainReactPackage() 26 | ); 27 | } 28 | }; 29 | 30 | @Override 31 | public ReactNativeHost getReactNativeHost() { 32 | return mReactNativeHost; 33 | } 34 | 35 | @Override 36 | public void onCreate() { 37 | super.onCreate(); 38 | SoLoader.init(this, /* native exopackage */ false); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /examples/SimpleExample/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gabrn/react-native-persistent-job/33d9cd11b1cddff91b0524b47b9b2b1818d9b0f5/examples/SimpleExample/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/SimpleExample/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gabrn/react-native-persistent-job/33d9cd11b1cddff91b0524b47b9b2b1818d9b0f5/examples/SimpleExample/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/SimpleExample/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gabrn/react-native-persistent-job/33d9cd11b1cddff91b0524b47b9b2b1818d9b0f5/examples/SimpleExample/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/SimpleExample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gabrn/react-native-persistent-job/33d9cd11b1cddff91b0524b47b9b2b1818d9b0f5/examples/SimpleExample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/SimpleExample/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | SimpleExample 3 | 4 | -------------------------------------------------------------------------------- /examples/SimpleExample/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /examples/SimpleExample/android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.2.3' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | mavenLocal() 18 | jcenter() 19 | maven { 20 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 21 | url "$rootDir/../node_modules/react-native/android" 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /examples/SimpleExample/android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | android.useDeprecatedNdk=true 21 | -------------------------------------------------------------------------------- /examples/SimpleExample/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gabrn/react-native-persistent-job/33d9cd11b1cddff91b0524b47b9b2b1818d9b0f5/examples/SimpleExample/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /examples/SimpleExample/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 6 | -------------------------------------------------------------------------------- /examples/SimpleExample/android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /examples/SimpleExample/android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /examples/SimpleExample/android/keystores/BUCK: -------------------------------------------------------------------------------- 1 | keystore( 2 | name = "debug", 3 | properties = "debug.keystore.properties", 4 | store = "debug.keystore", 5 | visibility = [ 6 | "PUBLIC", 7 | ], 8 | ) 9 | -------------------------------------------------------------------------------- /examples/SimpleExample/android/keystores/debug.keystore.properties: -------------------------------------------------------------------------------- 1 | key.store=debug.keystore 2 | key.alias=androiddebugkey 3 | key.store.password=android 4 | key.alias.password=android 5 | -------------------------------------------------------------------------------- /examples/SimpleExample/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'SimpleExample' 2 | 3 | include ':app' 4 | -------------------------------------------------------------------------------- /examples/SimpleExample/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "SimpleExample", 3 | "displayName": "SimpleExample" 4 | } -------------------------------------------------------------------------------- /examples/SimpleExample/index.android.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Sample React Native App 3 | * https://github.com/facebook/react-native 4 | * @flow 5 | */ 6 | 7 | import React, { Component } from 'react'; 8 | import { 9 | AppRegistry, 10 | StyleSheet, 11 | Text, 12 | View 13 | } from 'react-native' 14 | import persistentJob, {streamModifiers} from 'react-native-persistent-job' 15 | 16 | const sleep = time => new Promise(res => setTimeout(() => res(), time)) 17 | const sleepAndWarn = async (msg, time) => { 18 | await sleep(time) 19 | console.warn(msg) 20 | } 21 | 22 | 23 | export default class exampleReactNative extends Component { 24 | async componentDidMount() { 25 | await persistentJob.initializeStore({ 26 | jobHandlers: [{jobType: 'sleepAndWarn', handleFunction: sleepAndWarn}], 27 | }) 28 | 29 | await persistentJob.initializeStore({ 30 | storeName: 'online-jobs', 31 | jobHandlers: [{jobType: 'sleepAndWarn', handleFunction: sleepAndWarn}], 32 | modifyJobStream: streamModifiers.runWhenOnline 33 | }) 34 | 35 | persistentJob.store().createJob('sleepAndWarn')('hello after one second', 1000) 36 | persistentJob.store().createJob('sleepAndWarn')('goodBye after ten seconds', 10000) 37 | await sleep(1) 38 | persistentJob.store('online-jobs').createJob('sleepAndWarn')('I will only run online after one second', 1000) 39 | persistentJob.store('online-jobs').createJob('sleepAndWarn')('I will only run online after two seconds', 2000) 40 | await sleep(20000) 41 | persistentJob.store('online-jobs').createJob('sleepAndWarn')( 42 | `I will be ran after 20 seconds so you can go offline and then run only when online after one second`, 43 | 1000 44 | ) 45 | } 46 | 47 | render() { 48 | return ( 49 | 50 | 51 | Welcome to React Native! 52 | 53 | 54 | To get started, edit index.android.js 55 | 56 | 57 | Double tap R on your keyboard to reload,{'\n'} 58 | Shake or press menu button for dev menu 59 | 60 | 61 | ); 62 | } 63 | } 64 | 65 | const styles = StyleSheet.create({ 66 | container: { 67 | flex: 1, 68 | justifyContent: 'center', 69 | alignItems: 'center', 70 | backgroundColor: '#F5FCFF', 71 | }, 72 | welcome: { 73 | fontSize: 20, 74 | textAlign: 'center', 75 | margin: 10, 76 | }, 77 | instructions: { 78 | textAlign: 'center', 79 | color: '#333333', 80 | marginBottom: 5, 81 | }, 82 | }); 83 | 84 | AppRegistry.registerComponent('SimpleExample', () => exampleReactNative); 85 | -------------------------------------------------------------------------------- /examples/SimpleExample/index.ios.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Sample React Native App 3 | * https://github.com/facebook/react-native 4 | * @flow 5 | */ 6 | 7 | import React, { Component } from 'react'; 8 | import { 9 | AppRegistry, 10 | StyleSheet, 11 | Text, 12 | View 13 | } from 'react-native'; 14 | 15 | export default class SimpleExample extends Component { 16 | render() { 17 | return ( 18 | 19 | 20 | Welcome to React Native! 21 | 22 | 23 | To get started, edit index.ios.js 24 | 25 | 26 | Press Cmd+R to reload,{'\n'} 27 | Cmd+D or shake for dev menu 28 | 29 | 30 | ); 31 | } 32 | } 33 | 34 | const styles = StyleSheet.create({ 35 | container: { 36 | flex: 1, 37 | justifyContent: 'center', 38 | alignItems: 'center', 39 | backgroundColor: '#F5FCFF', 40 | }, 41 | welcome: { 42 | fontSize: 20, 43 | textAlign: 'center', 44 | margin: 10, 45 | }, 46 | instructions: { 47 | textAlign: 'center', 48 | color: '#333333', 49 | marginBottom: 5, 50 | }, 51 | }); 52 | 53 | AppRegistry.registerComponent('SimpleExample', () => SimpleExample); 54 | -------------------------------------------------------------------------------- /examples/SimpleExample/ios/SimpleExample-tvOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UIViewControllerBasedStatusBarAppearance 38 | 39 | NSLocationWhenInUseUsageDescription 40 | 41 | NSAppTransportSecurity 42 | 43 | 44 | NSExceptionDomains 45 | 46 | localhost 47 | 48 | NSExceptionAllowsInsecureHTTPLoads 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /examples/SimpleExample/ios/SimpleExample-tvOSTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /examples/SimpleExample/ios/SimpleExample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; }; 11 | 00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; }; 12 | 00C302E81ABCBA2D00DB3ED1 /* libRCTImage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302C01ABCB91800DB3ED1 /* libRCTImage.a */; }; 13 | 00C302E91ABCBA2D00DB3ED1 /* libRCTNetwork.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302DC1ABCB9D200DB3ED1 /* libRCTNetwork.a */; }; 14 | 00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */; }; 15 | 00E356F31AD99517003FC87E /* SimpleExampleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* SimpleExampleTests.m */; }; 16 | 133E29F31AD74F7200F7D852 /* libRCTLinking.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 78C398B91ACF4ADC00677621 /* libRCTLinking.a */; }; 17 | 139105C61AF99C1200B5F7CC /* libRCTSettings.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 139105C11AF99BAD00B5F7CC /* libRCTSettings.a */; }; 18 | 139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 139FDEF41B06529B00C62182 /* libRCTWebSocket.a */; }; 19 | 13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; }; 20 | 13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB11A68108700A75B9A /* LaunchScreen.xib */; }; 21 | 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; }; 22 | 13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; }; 23 | 140ED2AC1D01E1AD002B40FF /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; }; 24 | 146834051AC3E58100842450 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; }; 25 | 2D02E4BC1E0B4A80006451C7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; }; 26 | 2D02E4BD1E0B4A84006451C7 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; }; 27 | 2D02E4BF1E0B4AB3006451C7 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; }; 28 | 2D02E4C21E0B4AEC006451C7 /* libRCTAnimation-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E9157351DD0AC6500FF2AA8 /* libRCTAnimation-tvOS.a */; }; 29 | 2D02E4C31E0B4AEC006451C7 /* libRCTImage-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAD3E841DF850E9000B6D8A /* libRCTImage-tvOS.a */; }; 30 | 2D02E4C41E0B4AEC006451C7 /* libRCTLinking-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAD3E881DF850E9000B6D8A /* libRCTLinking-tvOS.a */; }; 31 | 2D02E4C51E0B4AEC006451C7 /* libRCTNetwork-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAD3E8C1DF850E9000B6D8A /* libRCTNetwork-tvOS.a */; }; 32 | 2D02E4C61E0B4AEC006451C7 /* libRCTSettings-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAD3E901DF850E9000B6D8A /* libRCTSettings-tvOS.a */; }; 33 | 2D02E4C71E0B4AEC006451C7 /* libRCTText-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAD3E941DF850E9000B6D8A /* libRCTText-tvOS.a */; }; 34 | 2D02E4C81E0B4AEC006451C7 /* libRCTWebSocket-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAD3E991DF850E9000B6D8A /* libRCTWebSocket-tvOS.a */; }; 35 | 2D02E4C91E0B4AEC006451C7 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAD3EA31DF850E9000B6D8A /* libReact.a */; }; 36 | 2DCD954D1E0B4F2C00145EB5 /* SimpleExampleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* SimpleExampleTests.m */; }; 37 | 5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */; }; 38 | 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; }; 39 | ADBDB9381DFEBF1600ED6528 /* libRCTBlob.a in Frameworks */ = {isa = PBXBuildFile; fileRef = ADBDB9271DFEBF0700ED6528 /* libRCTBlob.a */; }; 40 | /* End PBXBuildFile section */ 41 | 42 | /* Begin PBXContainerItemProxy section */ 43 | 00C302AB1ABCB8CE00DB3ED1 /* PBXContainerItemProxy */ = { 44 | isa = PBXContainerItemProxy; 45 | containerPortal = 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */; 46 | proxyType = 2; 47 | remoteGlobalIDString = 134814201AA4EA6300B7C361; 48 | remoteInfo = RCTActionSheet; 49 | }; 50 | 00C302B91ABCB90400DB3ED1 /* PBXContainerItemProxy */ = { 51 | isa = PBXContainerItemProxy; 52 | containerPortal = 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */; 53 | proxyType = 2; 54 | remoteGlobalIDString = 134814201AA4EA6300B7C361; 55 | remoteInfo = RCTGeolocation; 56 | }; 57 | 00C302BF1ABCB91800DB3ED1 /* PBXContainerItemProxy */ = { 58 | isa = PBXContainerItemProxy; 59 | containerPortal = 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */; 60 | proxyType = 2; 61 | remoteGlobalIDString = 58B5115D1A9E6B3D00147676; 62 | remoteInfo = RCTImage; 63 | }; 64 | 00C302DB1ABCB9D200DB3ED1 /* PBXContainerItemProxy */ = { 65 | isa = PBXContainerItemProxy; 66 | containerPortal = 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */; 67 | proxyType = 2; 68 | remoteGlobalIDString = 58B511DB1A9E6C8500147676; 69 | remoteInfo = RCTNetwork; 70 | }; 71 | 00C302E31ABCB9EE00DB3ED1 /* PBXContainerItemProxy */ = { 72 | isa = PBXContainerItemProxy; 73 | containerPortal = 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */; 74 | proxyType = 2; 75 | remoteGlobalIDString = 832C81801AAF6DEF007FA2F7; 76 | remoteInfo = RCTVibration; 77 | }; 78 | 00E356F41AD99517003FC87E /* PBXContainerItemProxy */ = { 79 | isa = PBXContainerItemProxy; 80 | containerPortal = 83CBB9F71A601CBA00E9B192 /* Project object */; 81 | proxyType = 1; 82 | remoteGlobalIDString = 13B07F861A680F5B00A75B9A; 83 | remoteInfo = SimpleExample; 84 | }; 85 | 139105C01AF99BAD00B5F7CC /* PBXContainerItemProxy */ = { 86 | isa = PBXContainerItemProxy; 87 | containerPortal = 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */; 88 | proxyType = 2; 89 | remoteGlobalIDString = 134814201AA4EA6300B7C361; 90 | remoteInfo = RCTSettings; 91 | }; 92 | 139FDEF31B06529B00C62182 /* PBXContainerItemProxy */ = { 93 | isa = PBXContainerItemProxy; 94 | containerPortal = 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */; 95 | proxyType = 2; 96 | remoteGlobalIDString = 3C86DF461ADF2C930047B81A; 97 | remoteInfo = RCTWebSocket; 98 | }; 99 | 146834031AC3E56700842450 /* PBXContainerItemProxy */ = { 100 | isa = PBXContainerItemProxy; 101 | containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; 102 | proxyType = 2; 103 | remoteGlobalIDString = 83CBBA2E1A601D0E00E9B192; 104 | remoteInfo = React; 105 | }; 106 | 2D02E4911E0B4A5D006451C7 /* PBXContainerItemProxy */ = { 107 | isa = PBXContainerItemProxy; 108 | containerPortal = 83CBB9F71A601CBA00E9B192 /* Project object */; 109 | proxyType = 1; 110 | remoteGlobalIDString = 2D02E47A1E0B4A5D006451C7; 111 | remoteInfo = "SimpleExample-tvOS"; 112 | }; 113 | 3DAD3E831DF850E9000B6D8A /* PBXContainerItemProxy */ = { 114 | isa = PBXContainerItemProxy; 115 | containerPortal = 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */; 116 | proxyType = 2; 117 | remoteGlobalIDString = 2D2A283A1D9B042B00D4039D; 118 | remoteInfo = "RCTImage-tvOS"; 119 | }; 120 | 3DAD3E871DF850E9000B6D8A /* PBXContainerItemProxy */ = { 121 | isa = PBXContainerItemProxy; 122 | containerPortal = 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */; 123 | proxyType = 2; 124 | remoteGlobalIDString = 2D2A28471D9B043800D4039D; 125 | remoteInfo = "RCTLinking-tvOS"; 126 | }; 127 | 3DAD3E8B1DF850E9000B6D8A /* PBXContainerItemProxy */ = { 128 | isa = PBXContainerItemProxy; 129 | containerPortal = 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */; 130 | proxyType = 2; 131 | remoteGlobalIDString = 2D2A28541D9B044C00D4039D; 132 | remoteInfo = "RCTNetwork-tvOS"; 133 | }; 134 | 3DAD3E8F1DF850E9000B6D8A /* PBXContainerItemProxy */ = { 135 | isa = PBXContainerItemProxy; 136 | containerPortal = 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */; 137 | proxyType = 2; 138 | remoteGlobalIDString = 2D2A28611D9B046600D4039D; 139 | remoteInfo = "RCTSettings-tvOS"; 140 | }; 141 | 3DAD3E931DF850E9000B6D8A /* PBXContainerItemProxy */ = { 142 | isa = PBXContainerItemProxy; 143 | containerPortal = 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */; 144 | proxyType = 2; 145 | remoteGlobalIDString = 2D2A287B1D9B048500D4039D; 146 | remoteInfo = "RCTText-tvOS"; 147 | }; 148 | 3DAD3E981DF850E9000B6D8A /* PBXContainerItemProxy */ = { 149 | isa = PBXContainerItemProxy; 150 | containerPortal = 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */; 151 | proxyType = 2; 152 | remoteGlobalIDString = 2D2A28881D9B049200D4039D; 153 | remoteInfo = "RCTWebSocket-tvOS"; 154 | }; 155 | 3DAD3EA21DF850E9000B6D8A /* PBXContainerItemProxy */ = { 156 | isa = PBXContainerItemProxy; 157 | containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; 158 | proxyType = 2; 159 | remoteGlobalIDString = 2D2A28131D9B038B00D4039D; 160 | remoteInfo = "React-tvOS"; 161 | }; 162 | 3DAD3EA41DF850E9000B6D8A /* PBXContainerItemProxy */ = { 163 | isa = PBXContainerItemProxy; 164 | containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; 165 | proxyType = 2; 166 | remoteGlobalIDString = 3D3C059A1DE3340900C268FA; 167 | remoteInfo = yoga; 168 | }; 169 | 3DAD3EA61DF850E9000B6D8A /* PBXContainerItemProxy */ = { 170 | isa = PBXContainerItemProxy; 171 | containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; 172 | proxyType = 2; 173 | remoteGlobalIDString = 3D3C06751DE3340C00C268FA; 174 | remoteInfo = "yoga-tvOS"; 175 | }; 176 | 3DAD3EA81DF850E9000B6D8A /* PBXContainerItemProxy */ = { 177 | isa = PBXContainerItemProxy; 178 | containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; 179 | proxyType = 2; 180 | remoteGlobalIDString = 3D3CD9251DE5FBEC00167DC4; 181 | remoteInfo = cxxreact; 182 | }; 183 | 3DAD3EAA1DF850E9000B6D8A /* PBXContainerItemProxy */ = { 184 | isa = PBXContainerItemProxy; 185 | containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; 186 | proxyType = 2; 187 | remoteGlobalIDString = 3D3CD9321DE5FBEE00167DC4; 188 | remoteInfo = "cxxreact-tvOS"; 189 | }; 190 | 3DAD3EAC1DF850E9000B6D8A /* PBXContainerItemProxy */ = { 191 | isa = PBXContainerItemProxy; 192 | containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; 193 | proxyType = 2; 194 | remoteGlobalIDString = 3D3CD90B1DE5FBD600167DC4; 195 | remoteInfo = jschelpers; 196 | }; 197 | 3DAD3EAE1DF850E9000B6D8A /* PBXContainerItemProxy */ = { 198 | isa = PBXContainerItemProxy; 199 | containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; 200 | proxyType = 2; 201 | remoteGlobalIDString = 3D3CD9181DE5FBD800167DC4; 202 | remoteInfo = "jschelpers-tvOS"; 203 | }; 204 | 5E9157321DD0AC6500FF2AA8 /* PBXContainerItemProxy */ = { 205 | isa = PBXContainerItemProxy; 206 | containerPortal = 5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */; 207 | proxyType = 2; 208 | remoteGlobalIDString = 134814201AA4EA6300B7C361; 209 | remoteInfo = RCTAnimation; 210 | }; 211 | 5E9157341DD0AC6500FF2AA8 /* PBXContainerItemProxy */ = { 212 | isa = PBXContainerItemProxy; 213 | containerPortal = 5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */; 214 | proxyType = 2; 215 | remoteGlobalIDString = 2D2A28201D9B03D100D4039D; 216 | remoteInfo = "RCTAnimation-tvOS"; 217 | }; 218 | 78C398B81ACF4ADC00677621 /* PBXContainerItemProxy */ = { 219 | isa = PBXContainerItemProxy; 220 | containerPortal = 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */; 221 | proxyType = 2; 222 | remoteGlobalIDString = 134814201AA4EA6300B7C361; 223 | remoteInfo = RCTLinking; 224 | }; 225 | 832341B41AAA6A8300B99B32 /* PBXContainerItemProxy */ = { 226 | isa = PBXContainerItemProxy; 227 | containerPortal = 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */; 228 | proxyType = 2; 229 | remoteGlobalIDString = 58B5119B1A9E6C1200147676; 230 | remoteInfo = RCTText; 231 | }; 232 | ADBDB9261DFEBF0700ED6528 /* PBXContainerItemProxy */ = { 233 | isa = PBXContainerItemProxy; 234 | containerPortal = ADBDB91F1DFEBF0600ED6528 /* RCTBlob.xcodeproj */; 235 | proxyType = 2; 236 | remoteGlobalIDString = 358F4ED71D1E81A9004DF814; 237 | remoteInfo = RCTBlob; 238 | }; 239 | /* End PBXContainerItemProxy section */ 240 | 241 | /* Begin PBXFileReference section */ 242 | 008F07F21AC5B25A0029DE68 /* main.jsbundle */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = main.jsbundle; sourceTree = ""; }; 243 | 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTActionSheet.xcodeproj; path = "../node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj"; sourceTree = ""; }; 244 | 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTGeolocation.xcodeproj; path = "../node_modules/react-native/Libraries/Geolocation/RCTGeolocation.xcodeproj"; sourceTree = ""; }; 245 | 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTImage.xcodeproj; path = "../node_modules/react-native/Libraries/Image/RCTImage.xcodeproj"; sourceTree = ""; }; 246 | 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTNetwork.xcodeproj; path = "../node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj"; sourceTree = ""; }; 247 | 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTVibration.xcodeproj; path = "../node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj"; sourceTree = ""; }; 248 | 00E356EE1AD99517003FC87E /* SimpleExampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SimpleExampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 249 | 00E356F11AD99517003FC87E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 250 | 00E356F21AD99517003FC87E /* SimpleExampleTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SimpleExampleTests.m; sourceTree = ""; }; 251 | 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTSettings.xcodeproj; path = "../node_modules/react-native/Libraries/Settings/RCTSettings.xcodeproj"; sourceTree = ""; }; 252 | 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTWebSocket.xcodeproj; path = "../node_modules/react-native/Libraries/WebSocket/RCTWebSocket.xcodeproj"; sourceTree = ""; }; 253 | 13B07F961A680F5B00A75B9A /* SimpleExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SimpleExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 254 | 13B07FAF1A68108700A75B9A /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = SimpleExample/AppDelegate.h; sourceTree = ""; }; 255 | 13B07FB01A68108700A75B9A /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = SimpleExample/AppDelegate.m; sourceTree = ""; }; 256 | 13B07FB21A68108700A75B9A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 257 | 13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = SimpleExample/Images.xcassets; sourceTree = ""; }; 258 | 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = SimpleExample/Info.plist; sourceTree = ""; }; 259 | 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = SimpleExample/main.m; sourceTree = ""; }; 260 | 146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = "../node_modules/react-native/React/React.xcodeproj"; sourceTree = ""; }; 261 | 2D02E47B1E0B4A5D006451C7 /* SimpleExample-tvOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "SimpleExample-tvOS.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 262 | 2D02E4901E0B4A5D006451C7 /* SimpleExample-tvOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SimpleExample-tvOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 263 | 5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTAnimation.xcodeproj; path = "../node_modules/react-native/Libraries/NativeAnimation/RCTAnimation.xcodeproj"; sourceTree = ""; }; 264 | 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = ""; }; 265 | 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = ""; }; 266 | ADBDB91F1DFEBF0600ED6528 /* RCTBlob.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTBlob.xcodeproj; path = "../node_modules/react-native/Libraries/Blob/RCTBlob.xcodeproj"; sourceTree = ""; }; 267 | /* End PBXFileReference section */ 268 | 269 | /* Begin PBXFrameworksBuildPhase section */ 270 | 00E356EB1AD99517003FC87E /* Frameworks */ = { 271 | isa = PBXFrameworksBuildPhase; 272 | buildActionMask = 2147483647; 273 | files = ( 274 | 140ED2AC1D01E1AD002B40FF /* libReact.a in Frameworks */, 275 | ); 276 | runOnlyForDeploymentPostprocessing = 0; 277 | }; 278 | 13B07F8C1A680F5B00A75B9A /* Frameworks */ = { 279 | isa = PBXFrameworksBuildPhase; 280 | buildActionMask = 2147483647; 281 | files = ( 282 | ADBDB9381DFEBF1600ED6528 /* libRCTBlob.a in Frameworks */, 283 | 5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */, 284 | 146834051AC3E58100842450 /* libReact.a in Frameworks */, 285 | 5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */, 286 | 00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */, 287 | 00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */, 288 | 00C302E81ABCBA2D00DB3ED1 /* libRCTImage.a in Frameworks */, 289 | 133E29F31AD74F7200F7D852 /* libRCTLinking.a in Frameworks */, 290 | 00C302E91ABCBA2D00DB3ED1 /* libRCTNetwork.a in Frameworks */, 291 | 139105C61AF99C1200B5F7CC /* libRCTSettings.a in Frameworks */, 292 | 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */, 293 | 00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */, 294 | 139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */, 295 | ); 296 | runOnlyForDeploymentPostprocessing = 0; 297 | }; 298 | 2D02E4781E0B4A5D006451C7 /* Frameworks */ = { 299 | isa = PBXFrameworksBuildPhase; 300 | buildActionMask = 2147483647; 301 | files = ( 302 | 2D02E4C91E0B4AEC006451C7 /* libReact.a in Frameworks */, 303 | 2D02E4C21E0B4AEC006451C7 /* libRCTAnimation-tvOS.a in Frameworks */, 304 | 2D02E4C31E0B4AEC006451C7 /* libRCTImage-tvOS.a in Frameworks */, 305 | 2D02E4C41E0B4AEC006451C7 /* libRCTLinking-tvOS.a in Frameworks */, 306 | 2D02E4C51E0B4AEC006451C7 /* libRCTNetwork-tvOS.a in Frameworks */, 307 | 2D02E4C61E0B4AEC006451C7 /* libRCTSettings-tvOS.a in Frameworks */, 308 | 2D02E4C71E0B4AEC006451C7 /* libRCTText-tvOS.a in Frameworks */, 309 | 2D02E4C81E0B4AEC006451C7 /* libRCTWebSocket-tvOS.a in Frameworks */, 310 | ); 311 | runOnlyForDeploymentPostprocessing = 0; 312 | }; 313 | 2D02E48D1E0B4A5D006451C7 /* Frameworks */ = { 314 | isa = PBXFrameworksBuildPhase; 315 | buildActionMask = 2147483647; 316 | files = ( 317 | ); 318 | runOnlyForDeploymentPostprocessing = 0; 319 | }; 320 | /* End PBXFrameworksBuildPhase section */ 321 | 322 | /* Begin PBXGroup section */ 323 | 00C302A81ABCB8CE00DB3ED1 /* Products */ = { 324 | isa = PBXGroup; 325 | children = ( 326 | 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */, 327 | ); 328 | name = Products; 329 | sourceTree = ""; 330 | }; 331 | 00C302B61ABCB90400DB3ED1 /* Products */ = { 332 | isa = PBXGroup; 333 | children = ( 334 | 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */, 335 | ); 336 | name = Products; 337 | sourceTree = ""; 338 | }; 339 | 00C302BC1ABCB91800DB3ED1 /* Products */ = { 340 | isa = PBXGroup; 341 | children = ( 342 | 00C302C01ABCB91800DB3ED1 /* libRCTImage.a */, 343 | 3DAD3E841DF850E9000B6D8A /* libRCTImage-tvOS.a */, 344 | ); 345 | name = Products; 346 | sourceTree = ""; 347 | }; 348 | 00C302D41ABCB9D200DB3ED1 /* Products */ = { 349 | isa = PBXGroup; 350 | children = ( 351 | 00C302DC1ABCB9D200DB3ED1 /* libRCTNetwork.a */, 352 | 3DAD3E8C1DF850E9000B6D8A /* libRCTNetwork-tvOS.a */, 353 | ); 354 | name = Products; 355 | sourceTree = ""; 356 | }; 357 | 00C302E01ABCB9EE00DB3ED1 /* Products */ = { 358 | isa = PBXGroup; 359 | children = ( 360 | 00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */, 361 | ); 362 | name = Products; 363 | sourceTree = ""; 364 | }; 365 | 00E356EF1AD99517003FC87E /* SimpleExampleTests */ = { 366 | isa = PBXGroup; 367 | children = ( 368 | 00E356F21AD99517003FC87E /* SimpleExampleTests.m */, 369 | 00E356F01AD99517003FC87E /* Supporting Files */, 370 | ); 371 | path = SimpleExampleTests; 372 | sourceTree = ""; 373 | }; 374 | 00E356F01AD99517003FC87E /* Supporting Files */ = { 375 | isa = PBXGroup; 376 | children = ( 377 | 00E356F11AD99517003FC87E /* Info.plist */, 378 | ); 379 | name = "Supporting Files"; 380 | sourceTree = ""; 381 | }; 382 | 139105B71AF99BAD00B5F7CC /* Products */ = { 383 | isa = PBXGroup; 384 | children = ( 385 | 139105C11AF99BAD00B5F7CC /* libRCTSettings.a */, 386 | 3DAD3E901DF850E9000B6D8A /* libRCTSettings-tvOS.a */, 387 | ); 388 | name = Products; 389 | sourceTree = ""; 390 | }; 391 | 139FDEE71B06529A00C62182 /* Products */ = { 392 | isa = PBXGroup; 393 | children = ( 394 | 139FDEF41B06529B00C62182 /* libRCTWebSocket.a */, 395 | 3DAD3E991DF850E9000B6D8A /* libRCTWebSocket-tvOS.a */, 396 | ); 397 | name = Products; 398 | sourceTree = ""; 399 | }; 400 | 13B07FAE1A68108700A75B9A /* SimpleExample */ = { 401 | isa = PBXGroup; 402 | children = ( 403 | 008F07F21AC5B25A0029DE68 /* main.jsbundle */, 404 | 13B07FAF1A68108700A75B9A /* AppDelegate.h */, 405 | 13B07FB01A68108700A75B9A /* AppDelegate.m */, 406 | 13B07FB51A68108700A75B9A /* Images.xcassets */, 407 | 13B07FB61A68108700A75B9A /* Info.plist */, 408 | 13B07FB11A68108700A75B9A /* LaunchScreen.xib */, 409 | 13B07FB71A68108700A75B9A /* main.m */, 410 | ); 411 | name = SimpleExample; 412 | sourceTree = ""; 413 | }; 414 | 146834001AC3E56700842450 /* Products */ = { 415 | isa = PBXGroup; 416 | children = ( 417 | 146834041AC3E56700842450 /* libReact.a */, 418 | 3DAD3EA31DF850E9000B6D8A /* libReact.a */, 419 | 3DAD3EA51DF850E9000B6D8A /* libyoga.a */, 420 | 3DAD3EA71DF850E9000B6D8A /* libyoga.a */, 421 | 3DAD3EA91DF850E9000B6D8A /* libcxxreact.a */, 422 | 3DAD3EAB1DF850E9000B6D8A /* libcxxreact.a */, 423 | 3DAD3EAD1DF850E9000B6D8A /* libjschelpers.a */, 424 | 3DAD3EAF1DF850E9000B6D8A /* libjschelpers.a */, 425 | 3DAD3EA31DF850E9000B6D8A /* libReact-tvOS.a */, 426 | ); 427 | name = Products; 428 | sourceTree = ""; 429 | }; 430 | 5E91572E1DD0AC6500FF2AA8 /* Products */ = { 431 | isa = PBXGroup; 432 | children = ( 433 | 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */, 434 | 5E9157351DD0AC6500FF2AA8 /* libRCTAnimation-tvOS.a */, 435 | ); 436 | name = Products; 437 | sourceTree = ""; 438 | }; 439 | 78C398B11ACF4ADC00677621 /* Products */ = { 440 | isa = PBXGroup; 441 | children = ( 442 | 78C398B91ACF4ADC00677621 /* libRCTLinking.a */, 443 | 3DAD3E881DF850E9000B6D8A /* libRCTLinking-tvOS.a */, 444 | ); 445 | name = Products; 446 | sourceTree = ""; 447 | }; 448 | 832341AE1AAA6A7D00B99B32 /* Libraries */ = { 449 | isa = PBXGroup; 450 | children = ( 451 | 5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */, 452 | 146833FF1AC3E56700842450 /* React.xcodeproj */, 453 | 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */, 454 | ADBDB91F1DFEBF0600ED6528 /* RCTBlob.xcodeproj */, 455 | 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */, 456 | 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */, 457 | 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */, 458 | 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */, 459 | 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */, 460 | 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */, 461 | 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */, 462 | 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */, 463 | ); 464 | name = Libraries; 465 | sourceTree = ""; 466 | }; 467 | 832341B11AAA6A8300B99B32 /* Products */ = { 468 | isa = PBXGroup; 469 | children = ( 470 | 832341B51AAA6A8300B99B32 /* libRCTText.a */, 471 | 3DAD3E941DF850E9000B6D8A /* libRCTText-tvOS.a */, 472 | ); 473 | name = Products; 474 | sourceTree = ""; 475 | }; 476 | 83CBB9F61A601CBA00E9B192 = { 477 | isa = PBXGroup; 478 | children = ( 479 | 13B07FAE1A68108700A75B9A /* SimpleExample */, 480 | 832341AE1AAA6A7D00B99B32 /* Libraries */, 481 | 00E356EF1AD99517003FC87E /* SimpleExampleTests */, 482 | 83CBBA001A601CBA00E9B192 /* Products */, 483 | ); 484 | indentWidth = 2; 485 | sourceTree = ""; 486 | tabWidth = 2; 487 | usesTabs = 0; 488 | }; 489 | 83CBBA001A601CBA00E9B192 /* Products */ = { 490 | isa = PBXGroup; 491 | children = ( 492 | 13B07F961A680F5B00A75B9A /* SimpleExample.app */, 493 | 00E356EE1AD99517003FC87E /* SimpleExampleTests.xctest */, 494 | 2D02E47B1E0B4A5D006451C7 /* SimpleExample-tvOS.app */, 495 | 2D02E4901E0B4A5D006451C7 /* SimpleExample-tvOSTests.xctest */, 496 | ); 497 | name = Products; 498 | sourceTree = ""; 499 | }; 500 | ADBDB9201DFEBF0600ED6528 /* Products */ = { 501 | isa = PBXGroup; 502 | children = ( 503 | ADBDB9271DFEBF0700ED6528 /* libRCTBlob.a */, 504 | ); 505 | name = Products; 506 | sourceTree = ""; 507 | }; 508 | /* End PBXGroup section */ 509 | 510 | /* Begin PBXNativeTarget section */ 511 | 00E356ED1AD99517003FC87E /* SimpleExampleTests */ = { 512 | isa = PBXNativeTarget; 513 | buildConfigurationList = 00E357021AD99517003FC87E /* Build configuration list for PBXNativeTarget "SimpleExampleTests" */; 514 | buildPhases = ( 515 | 00E356EA1AD99517003FC87E /* Sources */, 516 | 00E356EB1AD99517003FC87E /* Frameworks */, 517 | 00E356EC1AD99517003FC87E /* Resources */, 518 | ); 519 | buildRules = ( 520 | ); 521 | dependencies = ( 522 | 00E356F51AD99517003FC87E /* PBXTargetDependency */, 523 | ); 524 | name = SimpleExampleTests; 525 | productName = SimpleExampleTests; 526 | productReference = 00E356EE1AD99517003FC87E /* SimpleExampleTests.xctest */; 527 | productType = "com.apple.product-type.bundle.unit-test"; 528 | }; 529 | 13B07F861A680F5B00A75B9A /* SimpleExample */ = { 530 | isa = PBXNativeTarget; 531 | buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "SimpleExample" */; 532 | buildPhases = ( 533 | 13B07F871A680F5B00A75B9A /* Sources */, 534 | 13B07F8C1A680F5B00A75B9A /* Frameworks */, 535 | 13B07F8E1A680F5B00A75B9A /* Resources */, 536 | 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */, 537 | ); 538 | buildRules = ( 539 | ); 540 | dependencies = ( 541 | ); 542 | name = SimpleExample; 543 | productName = "Hello World"; 544 | productReference = 13B07F961A680F5B00A75B9A /* SimpleExample.app */; 545 | productType = "com.apple.product-type.application"; 546 | }; 547 | 2D02E47A1E0B4A5D006451C7 /* SimpleExample-tvOS */ = { 548 | isa = PBXNativeTarget; 549 | buildConfigurationList = 2D02E4BA1E0B4A5E006451C7 /* Build configuration list for PBXNativeTarget "SimpleExample-tvOS" */; 550 | buildPhases = ( 551 | 2D02E4771E0B4A5D006451C7 /* Sources */, 552 | 2D02E4781E0B4A5D006451C7 /* Frameworks */, 553 | 2D02E4791E0B4A5D006451C7 /* Resources */, 554 | 2D02E4CB1E0B4B27006451C7 /* Bundle React Native Code And Images */, 555 | ); 556 | buildRules = ( 557 | ); 558 | dependencies = ( 559 | ); 560 | name = "SimpleExample-tvOS"; 561 | productName = "SimpleExample-tvOS"; 562 | productReference = 2D02E47B1E0B4A5D006451C7 /* SimpleExample-tvOS.app */; 563 | productType = "com.apple.product-type.application"; 564 | }; 565 | 2D02E48F1E0B4A5D006451C7 /* SimpleExample-tvOSTests */ = { 566 | isa = PBXNativeTarget; 567 | buildConfigurationList = 2D02E4BB1E0B4A5E006451C7 /* Build configuration list for PBXNativeTarget "SimpleExample-tvOSTests" */; 568 | buildPhases = ( 569 | 2D02E48C1E0B4A5D006451C7 /* Sources */, 570 | 2D02E48D1E0B4A5D006451C7 /* Frameworks */, 571 | 2D02E48E1E0B4A5D006451C7 /* Resources */, 572 | ); 573 | buildRules = ( 574 | ); 575 | dependencies = ( 576 | 2D02E4921E0B4A5D006451C7 /* PBXTargetDependency */, 577 | ); 578 | name = "SimpleExample-tvOSTests"; 579 | productName = "SimpleExample-tvOSTests"; 580 | productReference = 2D02E4901E0B4A5D006451C7 /* SimpleExample-tvOSTests.xctest */; 581 | productType = "com.apple.product-type.bundle.unit-test"; 582 | }; 583 | /* End PBXNativeTarget section */ 584 | 585 | /* Begin PBXProject section */ 586 | 83CBB9F71A601CBA00E9B192 /* Project object */ = { 587 | isa = PBXProject; 588 | attributes = { 589 | LastUpgradeCheck = 0610; 590 | ORGANIZATIONNAME = Facebook; 591 | TargetAttributes = { 592 | 00E356ED1AD99517003FC87E = { 593 | CreatedOnToolsVersion = 6.2; 594 | TestTargetID = 13B07F861A680F5B00A75B9A; 595 | }; 596 | 2D02E47A1E0B4A5D006451C7 = { 597 | CreatedOnToolsVersion = 8.2.1; 598 | ProvisioningStyle = Automatic; 599 | }; 600 | 2D02E48F1E0B4A5D006451C7 = { 601 | CreatedOnToolsVersion = 8.2.1; 602 | ProvisioningStyle = Automatic; 603 | TestTargetID = 2D02E47A1E0B4A5D006451C7; 604 | }; 605 | }; 606 | }; 607 | buildConfigurationList = 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "SimpleExample" */; 608 | compatibilityVersion = "Xcode 3.2"; 609 | developmentRegion = English; 610 | hasScannedForEncodings = 0; 611 | knownRegions = ( 612 | en, 613 | Base, 614 | ); 615 | mainGroup = 83CBB9F61A601CBA00E9B192; 616 | productRefGroup = 83CBBA001A601CBA00E9B192 /* Products */; 617 | projectDirPath = ""; 618 | projectReferences = ( 619 | { 620 | ProductGroup = 00C302A81ABCB8CE00DB3ED1 /* Products */; 621 | ProjectRef = 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */; 622 | }, 623 | { 624 | ProductGroup = 5E91572E1DD0AC6500FF2AA8 /* Products */; 625 | ProjectRef = 5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */; 626 | }, 627 | { 628 | ProductGroup = ADBDB9201DFEBF0600ED6528 /* Products */; 629 | ProjectRef = ADBDB91F1DFEBF0600ED6528 /* RCTBlob.xcodeproj */; 630 | }, 631 | { 632 | ProductGroup = 00C302B61ABCB90400DB3ED1 /* Products */; 633 | ProjectRef = 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */; 634 | }, 635 | { 636 | ProductGroup = 00C302BC1ABCB91800DB3ED1 /* Products */; 637 | ProjectRef = 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */; 638 | }, 639 | { 640 | ProductGroup = 78C398B11ACF4ADC00677621 /* Products */; 641 | ProjectRef = 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */; 642 | }, 643 | { 644 | ProductGroup = 00C302D41ABCB9D200DB3ED1 /* Products */; 645 | ProjectRef = 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */; 646 | }, 647 | { 648 | ProductGroup = 139105B71AF99BAD00B5F7CC /* Products */; 649 | ProjectRef = 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */; 650 | }, 651 | { 652 | ProductGroup = 832341B11AAA6A8300B99B32 /* Products */; 653 | ProjectRef = 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */; 654 | }, 655 | { 656 | ProductGroup = 00C302E01ABCB9EE00DB3ED1 /* Products */; 657 | ProjectRef = 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */; 658 | }, 659 | { 660 | ProductGroup = 139FDEE71B06529A00C62182 /* Products */; 661 | ProjectRef = 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */; 662 | }, 663 | { 664 | ProductGroup = 146834001AC3E56700842450 /* Products */; 665 | ProjectRef = 146833FF1AC3E56700842450 /* React.xcodeproj */; 666 | }, 667 | ); 668 | projectRoot = ""; 669 | targets = ( 670 | 13B07F861A680F5B00A75B9A /* SimpleExample */, 671 | 00E356ED1AD99517003FC87E /* SimpleExampleTests */, 672 | 2D02E47A1E0B4A5D006451C7 /* SimpleExample-tvOS */, 673 | 2D02E48F1E0B4A5D006451C7 /* SimpleExample-tvOSTests */, 674 | ); 675 | }; 676 | /* End PBXProject section */ 677 | 678 | /* Begin PBXReferenceProxy section */ 679 | 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */ = { 680 | isa = PBXReferenceProxy; 681 | fileType = archive.ar; 682 | path = libRCTActionSheet.a; 683 | remoteRef = 00C302AB1ABCB8CE00DB3ED1 /* PBXContainerItemProxy */; 684 | sourceTree = BUILT_PRODUCTS_DIR; 685 | }; 686 | 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */ = { 687 | isa = PBXReferenceProxy; 688 | fileType = archive.ar; 689 | path = libRCTGeolocation.a; 690 | remoteRef = 00C302B91ABCB90400DB3ED1 /* PBXContainerItemProxy */; 691 | sourceTree = BUILT_PRODUCTS_DIR; 692 | }; 693 | 00C302C01ABCB91800DB3ED1 /* libRCTImage.a */ = { 694 | isa = PBXReferenceProxy; 695 | fileType = archive.ar; 696 | path = libRCTImage.a; 697 | remoteRef = 00C302BF1ABCB91800DB3ED1 /* PBXContainerItemProxy */; 698 | sourceTree = BUILT_PRODUCTS_DIR; 699 | }; 700 | 00C302DC1ABCB9D200DB3ED1 /* libRCTNetwork.a */ = { 701 | isa = PBXReferenceProxy; 702 | fileType = archive.ar; 703 | path = libRCTNetwork.a; 704 | remoteRef = 00C302DB1ABCB9D200DB3ED1 /* PBXContainerItemProxy */; 705 | sourceTree = BUILT_PRODUCTS_DIR; 706 | }; 707 | 00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */ = { 708 | isa = PBXReferenceProxy; 709 | fileType = archive.ar; 710 | path = libRCTVibration.a; 711 | remoteRef = 00C302E31ABCB9EE00DB3ED1 /* PBXContainerItemProxy */; 712 | sourceTree = BUILT_PRODUCTS_DIR; 713 | }; 714 | 139105C11AF99BAD00B5F7CC /* libRCTSettings.a */ = { 715 | isa = PBXReferenceProxy; 716 | fileType = archive.ar; 717 | path = libRCTSettings.a; 718 | remoteRef = 139105C01AF99BAD00B5F7CC /* PBXContainerItemProxy */; 719 | sourceTree = BUILT_PRODUCTS_DIR; 720 | }; 721 | 139FDEF41B06529B00C62182 /* libRCTWebSocket.a */ = { 722 | isa = PBXReferenceProxy; 723 | fileType = archive.ar; 724 | path = libRCTWebSocket.a; 725 | remoteRef = 139FDEF31B06529B00C62182 /* PBXContainerItemProxy */; 726 | sourceTree = BUILT_PRODUCTS_DIR; 727 | }; 728 | 146834041AC3E56700842450 /* libReact.a */ = { 729 | isa = PBXReferenceProxy; 730 | fileType = archive.ar; 731 | path = libReact.a; 732 | remoteRef = 146834031AC3E56700842450 /* PBXContainerItemProxy */; 733 | sourceTree = BUILT_PRODUCTS_DIR; 734 | }; 735 | 3DAD3E841DF850E9000B6D8A /* libRCTImage-tvOS.a */ = { 736 | isa = PBXReferenceProxy; 737 | fileType = archive.ar; 738 | path = "libRCTImage-tvOS.a"; 739 | remoteRef = 3DAD3E831DF850E9000B6D8A /* PBXContainerItemProxy */; 740 | sourceTree = BUILT_PRODUCTS_DIR; 741 | }; 742 | 3DAD3E881DF850E9000B6D8A /* libRCTLinking-tvOS.a */ = { 743 | isa = PBXReferenceProxy; 744 | fileType = archive.ar; 745 | path = "libRCTLinking-tvOS.a"; 746 | remoteRef = 3DAD3E871DF850E9000B6D8A /* PBXContainerItemProxy */; 747 | sourceTree = BUILT_PRODUCTS_DIR; 748 | }; 749 | 3DAD3E8C1DF850E9000B6D8A /* libRCTNetwork-tvOS.a */ = { 750 | isa = PBXReferenceProxy; 751 | fileType = archive.ar; 752 | path = "libRCTNetwork-tvOS.a"; 753 | remoteRef = 3DAD3E8B1DF850E9000B6D8A /* PBXContainerItemProxy */; 754 | sourceTree = BUILT_PRODUCTS_DIR; 755 | }; 756 | 3DAD3E901DF850E9000B6D8A /* libRCTSettings-tvOS.a */ = { 757 | isa = PBXReferenceProxy; 758 | fileType = archive.ar; 759 | path = "libRCTSettings-tvOS.a"; 760 | remoteRef = 3DAD3E8F1DF850E9000B6D8A /* PBXContainerItemProxy */; 761 | sourceTree = BUILT_PRODUCTS_DIR; 762 | }; 763 | 3DAD3E941DF850E9000B6D8A /* libRCTText-tvOS.a */ = { 764 | isa = PBXReferenceProxy; 765 | fileType = archive.ar; 766 | path = "libRCTText-tvOS.a"; 767 | remoteRef = 3DAD3E931DF850E9000B6D8A /* PBXContainerItemProxy */; 768 | sourceTree = BUILT_PRODUCTS_DIR; 769 | }; 770 | 3DAD3E991DF850E9000B6D8A /* libRCTWebSocket-tvOS.a */ = { 771 | isa = PBXReferenceProxy; 772 | fileType = archive.ar; 773 | path = "libRCTWebSocket-tvOS.a"; 774 | remoteRef = 3DAD3E981DF850E9000B6D8A /* PBXContainerItemProxy */; 775 | sourceTree = BUILT_PRODUCTS_DIR; 776 | }; 777 | 3DAD3EA31DF850E9000B6D8A /* libReact-tvOS.a */ = { 778 | isa = PBXReferenceProxy; 779 | fileType = archive.ar; 780 | path = "libReact-tvOS.a"; 781 | remoteRef = 3DAD3EA21DF850E9000B6D8A /* PBXContainerItemProxy */; 782 | sourceTree = BUILT_PRODUCTS_DIR; 783 | }; 784 | 3DAD3EA51DF850E9000B6D8A /* libyoga.a */ = { 785 | isa = PBXReferenceProxy; 786 | fileType = archive.ar; 787 | path = libyoga.a; 788 | remoteRef = 3DAD3EA41DF850E9000B6D8A /* PBXContainerItemProxy */; 789 | sourceTree = BUILT_PRODUCTS_DIR; 790 | }; 791 | 3DAD3EA71DF850E9000B6D8A /* libyoga.a */ = { 792 | isa = PBXReferenceProxy; 793 | fileType = archive.ar; 794 | path = libyoga.a; 795 | remoteRef = 3DAD3EA61DF850E9000B6D8A /* PBXContainerItemProxy */; 796 | sourceTree = BUILT_PRODUCTS_DIR; 797 | }; 798 | 3DAD3EA91DF850E9000B6D8A /* libcxxreact.a */ = { 799 | isa = PBXReferenceProxy; 800 | fileType = archive.ar; 801 | path = libcxxreact.a; 802 | remoteRef = 3DAD3EA81DF850E9000B6D8A /* PBXContainerItemProxy */; 803 | sourceTree = BUILT_PRODUCTS_DIR; 804 | }; 805 | 3DAD3EAB1DF850E9000B6D8A /* libcxxreact.a */ = { 806 | isa = PBXReferenceProxy; 807 | fileType = archive.ar; 808 | path = libcxxreact.a; 809 | remoteRef = 3DAD3EAA1DF850E9000B6D8A /* PBXContainerItemProxy */; 810 | sourceTree = BUILT_PRODUCTS_DIR; 811 | }; 812 | 3DAD3EAD1DF850E9000B6D8A /* libjschelpers.a */ = { 813 | isa = PBXReferenceProxy; 814 | fileType = archive.ar; 815 | path = libjschelpers.a; 816 | remoteRef = 3DAD3EAC1DF850E9000B6D8A /* PBXContainerItemProxy */; 817 | sourceTree = BUILT_PRODUCTS_DIR; 818 | }; 819 | 3DAD3EAF1DF850E9000B6D8A /* libjschelpers.a */ = { 820 | isa = PBXReferenceProxy; 821 | fileType = archive.ar; 822 | path = libjschelpers.a; 823 | remoteRef = 3DAD3EAE1DF850E9000B6D8A /* PBXContainerItemProxy */; 824 | sourceTree = BUILT_PRODUCTS_DIR; 825 | }; 826 | 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */ = { 827 | isa = PBXReferenceProxy; 828 | fileType = archive.ar; 829 | path = libRCTAnimation.a; 830 | remoteRef = 5E9157321DD0AC6500FF2AA8 /* PBXContainerItemProxy */; 831 | sourceTree = BUILT_PRODUCTS_DIR; 832 | }; 833 | 5E9157351DD0AC6500FF2AA8 /* libRCTAnimation-tvOS.a */ = { 834 | isa = PBXReferenceProxy; 835 | fileType = archive.ar; 836 | path = "libRCTAnimation-tvOS.a"; 837 | remoteRef = 5E9157341DD0AC6500FF2AA8 /* PBXContainerItemProxy */; 838 | sourceTree = BUILT_PRODUCTS_DIR; 839 | }; 840 | 78C398B91ACF4ADC00677621 /* libRCTLinking.a */ = { 841 | isa = PBXReferenceProxy; 842 | fileType = archive.ar; 843 | path = libRCTLinking.a; 844 | remoteRef = 78C398B81ACF4ADC00677621 /* PBXContainerItemProxy */; 845 | sourceTree = BUILT_PRODUCTS_DIR; 846 | }; 847 | 832341B51AAA6A8300B99B32 /* libRCTText.a */ = { 848 | isa = PBXReferenceProxy; 849 | fileType = archive.ar; 850 | path = libRCTText.a; 851 | remoteRef = 832341B41AAA6A8300B99B32 /* PBXContainerItemProxy */; 852 | sourceTree = BUILT_PRODUCTS_DIR; 853 | }; 854 | ADBDB9271DFEBF0700ED6528 /* libRCTBlob.a */ = { 855 | isa = PBXReferenceProxy; 856 | fileType = archive.ar; 857 | path = libRCTBlob.a; 858 | remoteRef = ADBDB9261DFEBF0700ED6528 /* PBXContainerItemProxy */; 859 | sourceTree = BUILT_PRODUCTS_DIR; 860 | }; 861 | /* End PBXReferenceProxy section */ 862 | 863 | /* Begin PBXResourcesBuildPhase section */ 864 | 00E356EC1AD99517003FC87E /* Resources */ = { 865 | isa = PBXResourcesBuildPhase; 866 | buildActionMask = 2147483647; 867 | files = ( 868 | ); 869 | runOnlyForDeploymentPostprocessing = 0; 870 | }; 871 | 13B07F8E1A680F5B00A75B9A /* Resources */ = { 872 | isa = PBXResourcesBuildPhase; 873 | buildActionMask = 2147483647; 874 | files = ( 875 | 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */, 876 | 13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */, 877 | ); 878 | runOnlyForDeploymentPostprocessing = 0; 879 | }; 880 | 2D02E4791E0B4A5D006451C7 /* Resources */ = { 881 | isa = PBXResourcesBuildPhase; 882 | buildActionMask = 2147483647; 883 | files = ( 884 | 2D02E4BD1E0B4A84006451C7 /* Images.xcassets in Resources */, 885 | ); 886 | runOnlyForDeploymentPostprocessing = 0; 887 | }; 888 | 2D02E48E1E0B4A5D006451C7 /* Resources */ = { 889 | isa = PBXResourcesBuildPhase; 890 | buildActionMask = 2147483647; 891 | files = ( 892 | ); 893 | runOnlyForDeploymentPostprocessing = 0; 894 | }; 895 | /* End PBXResourcesBuildPhase section */ 896 | 897 | /* Begin PBXShellScriptBuildPhase section */ 898 | 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */ = { 899 | isa = PBXShellScriptBuildPhase; 900 | buildActionMask = 2147483647; 901 | files = ( 902 | ); 903 | inputPaths = ( 904 | ); 905 | name = "Bundle React Native code and images"; 906 | outputPaths = ( 907 | ); 908 | runOnlyForDeploymentPostprocessing = 0; 909 | shellPath = /bin/sh; 910 | shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh"; 911 | }; 912 | 2D02E4CB1E0B4B27006451C7 /* Bundle React Native Code And Images */ = { 913 | isa = PBXShellScriptBuildPhase; 914 | buildActionMask = 2147483647; 915 | files = ( 916 | ); 917 | inputPaths = ( 918 | ); 919 | name = "Bundle React Native Code And Images"; 920 | outputPaths = ( 921 | ); 922 | runOnlyForDeploymentPostprocessing = 0; 923 | shellPath = /bin/sh; 924 | shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh"; 925 | }; 926 | /* End PBXShellScriptBuildPhase section */ 927 | 928 | /* Begin PBXSourcesBuildPhase section */ 929 | 00E356EA1AD99517003FC87E /* Sources */ = { 930 | isa = PBXSourcesBuildPhase; 931 | buildActionMask = 2147483647; 932 | files = ( 933 | 00E356F31AD99517003FC87E /* SimpleExampleTests.m in Sources */, 934 | ); 935 | runOnlyForDeploymentPostprocessing = 0; 936 | }; 937 | 13B07F871A680F5B00A75B9A /* Sources */ = { 938 | isa = PBXSourcesBuildPhase; 939 | buildActionMask = 2147483647; 940 | files = ( 941 | 13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */, 942 | 13B07FC11A68108700A75B9A /* main.m in Sources */, 943 | ); 944 | runOnlyForDeploymentPostprocessing = 0; 945 | }; 946 | 2D02E4771E0B4A5D006451C7 /* Sources */ = { 947 | isa = PBXSourcesBuildPhase; 948 | buildActionMask = 2147483647; 949 | files = ( 950 | 2D02E4BF1E0B4AB3006451C7 /* main.m in Sources */, 951 | 2D02E4BC1E0B4A80006451C7 /* AppDelegate.m in Sources */, 952 | ); 953 | runOnlyForDeploymentPostprocessing = 0; 954 | }; 955 | 2D02E48C1E0B4A5D006451C7 /* Sources */ = { 956 | isa = PBXSourcesBuildPhase; 957 | buildActionMask = 2147483647; 958 | files = ( 959 | 2DCD954D1E0B4F2C00145EB5 /* SimpleExampleTests.m in Sources */, 960 | ); 961 | runOnlyForDeploymentPostprocessing = 0; 962 | }; 963 | /* End PBXSourcesBuildPhase section */ 964 | 965 | /* Begin PBXTargetDependency section */ 966 | 00E356F51AD99517003FC87E /* PBXTargetDependency */ = { 967 | isa = PBXTargetDependency; 968 | target = 13B07F861A680F5B00A75B9A /* SimpleExample */; 969 | targetProxy = 00E356F41AD99517003FC87E /* PBXContainerItemProxy */; 970 | }; 971 | 2D02E4921E0B4A5D006451C7 /* PBXTargetDependency */ = { 972 | isa = PBXTargetDependency; 973 | target = 2D02E47A1E0B4A5D006451C7 /* SimpleExample-tvOS */; 974 | targetProxy = 2D02E4911E0B4A5D006451C7 /* PBXContainerItemProxy */; 975 | }; 976 | /* End PBXTargetDependency section */ 977 | 978 | /* Begin PBXVariantGroup section */ 979 | 13B07FB11A68108700A75B9A /* LaunchScreen.xib */ = { 980 | isa = PBXVariantGroup; 981 | children = ( 982 | 13B07FB21A68108700A75B9A /* Base */, 983 | ); 984 | name = LaunchScreen.xib; 985 | path = SimpleExample; 986 | sourceTree = ""; 987 | }; 988 | /* End PBXVariantGroup section */ 989 | 990 | /* Begin XCBuildConfiguration section */ 991 | 00E356F61AD99517003FC87E /* Debug */ = { 992 | isa = XCBuildConfiguration; 993 | buildSettings = { 994 | BUNDLE_LOADER = "$(TEST_HOST)"; 995 | GCC_PREPROCESSOR_DEFINITIONS = ( 996 | "DEBUG=1", 997 | "$(inherited)", 998 | ); 999 | INFOPLIST_FILE = SimpleExampleTests/Info.plist; 1000 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 1001 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 1002 | OTHER_LDFLAGS = ( 1003 | "-ObjC", 1004 | "-lc++", 1005 | ); 1006 | PRODUCT_NAME = "$(TARGET_NAME)"; 1007 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SimpleExample.app/SimpleExample"; 1008 | }; 1009 | name = Debug; 1010 | }; 1011 | 00E356F71AD99517003FC87E /* Release */ = { 1012 | isa = XCBuildConfiguration; 1013 | buildSettings = { 1014 | BUNDLE_LOADER = "$(TEST_HOST)"; 1015 | COPY_PHASE_STRIP = NO; 1016 | INFOPLIST_FILE = SimpleExampleTests/Info.plist; 1017 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 1018 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 1019 | OTHER_LDFLAGS = ( 1020 | "-ObjC", 1021 | "-lc++", 1022 | ); 1023 | PRODUCT_NAME = "$(TARGET_NAME)"; 1024 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SimpleExample.app/SimpleExample"; 1025 | }; 1026 | name = Release; 1027 | }; 1028 | 13B07F941A680F5B00A75B9A /* Debug */ = { 1029 | isa = XCBuildConfiguration; 1030 | buildSettings = { 1031 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 1032 | CURRENT_PROJECT_VERSION = 1; 1033 | DEAD_CODE_STRIPPING = NO; 1034 | INFOPLIST_FILE = SimpleExample/Info.plist; 1035 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 1036 | OTHER_LDFLAGS = ( 1037 | "$(inherited)", 1038 | "-ObjC", 1039 | "-lc++", 1040 | ); 1041 | PRODUCT_NAME = SimpleExample; 1042 | VERSIONING_SYSTEM = "apple-generic"; 1043 | }; 1044 | name = Debug; 1045 | }; 1046 | 13B07F951A680F5B00A75B9A /* Release */ = { 1047 | isa = XCBuildConfiguration; 1048 | buildSettings = { 1049 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 1050 | CURRENT_PROJECT_VERSION = 1; 1051 | INFOPLIST_FILE = SimpleExample/Info.plist; 1052 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 1053 | OTHER_LDFLAGS = ( 1054 | "$(inherited)", 1055 | "-ObjC", 1056 | "-lc++", 1057 | ); 1058 | PRODUCT_NAME = SimpleExample; 1059 | VERSIONING_SYSTEM = "apple-generic"; 1060 | }; 1061 | name = Release; 1062 | }; 1063 | 2D02E4971E0B4A5E006451C7 /* Debug */ = { 1064 | isa = XCBuildConfiguration; 1065 | buildSettings = { 1066 | ASSETCATALOG_COMPILER_APPICON_NAME = "App Icon & Top Shelf Image"; 1067 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 1068 | CLANG_ANALYZER_NONNULL = YES; 1069 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 1070 | CLANG_WARN_INFINITE_RECURSION = YES; 1071 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 1072 | DEBUG_INFORMATION_FORMAT = dwarf; 1073 | ENABLE_TESTABILITY = YES; 1074 | GCC_NO_COMMON_BLOCKS = YES; 1075 | INFOPLIST_FILE = "SimpleExample-tvOS/Info.plist"; 1076 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 1077 | OTHER_LDFLAGS = ( 1078 | "-ObjC", 1079 | "-lc++", 1080 | ); 1081 | PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.REACT.SimpleExample-tvOS"; 1082 | PRODUCT_NAME = "$(TARGET_NAME)"; 1083 | SDKROOT = appletvos; 1084 | TARGETED_DEVICE_FAMILY = 3; 1085 | TVOS_DEPLOYMENT_TARGET = 9.2; 1086 | }; 1087 | name = Debug; 1088 | }; 1089 | 2D02E4981E0B4A5E006451C7 /* Release */ = { 1090 | isa = XCBuildConfiguration; 1091 | buildSettings = { 1092 | ASSETCATALOG_COMPILER_APPICON_NAME = "App Icon & Top Shelf Image"; 1093 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 1094 | CLANG_ANALYZER_NONNULL = YES; 1095 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 1096 | CLANG_WARN_INFINITE_RECURSION = YES; 1097 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 1098 | COPY_PHASE_STRIP = NO; 1099 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 1100 | GCC_NO_COMMON_BLOCKS = YES; 1101 | INFOPLIST_FILE = "SimpleExample-tvOS/Info.plist"; 1102 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 1103 | OTHER_LDFLAGS = ( 1104 | "-ObjC", 1105 | "-lc++", 1106 | ); 1107 | PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.REACT.SimpleExample-tvOS"; 1108 | PRODUCT_NAME = "$(TARGET_NAME)"; 1109 | SDKROOT = appletvos; 1110 | TARGETED_DEVICE_FAMILY = 3; 1111 | TVOS_DEPLOYMENT_TARGET = 9.2; 1112 | }; 1113 | name = Release; 1114 | }; 1115 | 2D02E4991E0B4A5E006451C7 /* Debug */ = { 1116 | isa = XCBuildConfiguration; 1117 | buildSettings = { 1118 | BUNDLE_LOADER = "$(TEST_HOST)"; 1119 | CLANG_ANALYZER_NONNULL = YES; 1120 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 1121 | CLANG_WARN_INFINITE_RECURSION = YES; 1122 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 1123 | DEBUG_INFORMATION_FORMAT = dwarf; 1124 | ENABLE_TESTABILITY = YES; 1125 | GCC_NO_COMMON_BLOCKS = YES; 1126 | INFOPLIST_FILE = "SimpleExample-tvOSTests/Info.plist"; 1127 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 1128 | PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.REACT.SimpleExample-tvOSTests"; 1129 | PRODUCT_NAME = "$(TARGET_NAME)"; 1130 | SDKROOT = appletvos; 1131 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SimpleExample-tvOS.app/SimpleExample-tvOS"; 1132 | TVOS_DEPLOYMENT_TARGET = 10.1; 1133 | }; 1134 | name = Debug; 1135 | }; 1136 | 2D02E49A1E0B4A5E006451C7 /* Release */ = { 1137 | isa = XCBuildConfiguration; 1138 | buildSettings = { 1139 | BUNDLE_LOADER = "$(TEST_HOST)"; 1140 | CLANG_ANALYZER_NONNULL = YES; 1141 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 1142 | CLANG_WARN_INFINITE_RECURSION = YES; 1143 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 1144 | COPY_PHASE_STRIP = NO; 1145 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 1146 | GCC_NO_COMMON_BLOCKS = YES; 1147 | INFOPLIST_FILE = "SimpleExample-tvOSTests/Info.plist"; 1148 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 1149 | PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.REACT.SimpleExample-tvOSTests"; 1150 | PRODUCT_NAME = "$(TARGET_NAME)"; 1151 | SDKROOT = appletvos; 1152 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SimpleExample-tvOS.app/SimpleExample-tvOS"; 1153 | TVOS_DEPLOYMENT_TARGET = 10.1; 1154 | }; 1155 | name = Release; 1156 | }; 1157 | 83CBBA201A601CBA00E9B192 /* Debug */ = { 1158 | isa = XCBuildConfiguration; 1159 | buildSettings = { 1160 | ALWAYS_SEARCH_USER_PATHS = NO; 1161 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 1162 | CLANG_CXX_LIBRARY = "libc++"; 1163 | CLANG_ENABLE_MODULES = YES; 1164 | CLANG_ENABLE_OBJC_ARC = YES; 1165 | CLANG_WARN_BOOL_CONVERSION = YES; 1166 | CLANG_WARN_CONSTANT_CONVERSION = YES; 1167 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 1168 | CLANG_WARN_EMPTY_BODY = YES; 1169 | CLANG_WARN_ENUM_CONVERSION = YES; 1170 | CLANG_WARN_INT_CONVERSION = YES; 1171 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 1172 | CLANG_WARN_UNREACHABLE_CODE = YES; 1173 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 1174 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 1175 | COPY_PHASE_STRIP = NO; 1176 | ENABLE_STRICT_OBJC_MSGSEND = YES; 1177 | GCC_C_LANGUAGE_STANDARD = gnu99; 1178 | GCC_DYNAMIC_NO_PIC = NO; 1179 | GCC_OPTIMIZATION_LEVEL = 0; 1180 | GCC_PREPROCESSOR_DEFINITIONS = ( 1181 | "DEBUG=1", 1182 | "$(inherited)", 1183 | ); 1184 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 1185 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 1186 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 1187 | GCC_WARN_UNDECLARED_SELECTOR = YES; 1188 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 1189 | GCC_WARN_UNUSED_FUNCTION = YES; 1190 | GCC_WARN_UNUSED_VARIABLE = YES; 1191 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 1192 | MTL_ENABLE_DEBUG_INFO = YES; 1193 | ONLY_ACTIVE_ARCH = YES; 1194 | SDKROOT = iphoneos; 1195 | }; 1196 | name = Debug; 1197 | }; 1198 | 83CBBA211A601CBA00E9B192 /* Release */ = { 1199 | isa = XCBuildConfiguration; 1200 | buildSettings = { 1201 | ALWAYS_SEARCH_USER_PATHS = NO; 1202 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 1203 | CLANG_CXX_LIBRARY = "libc++"; 1204 | CLANG_ENABLE_MODULES = YES; 1205 | CLANG_ENABLE_OBJC_ARC = YES; 1206 | CLANG_WARN_BOOL_CONVERSION = YES; 1207 | CLANG_WARN_CONSTANT_CONVERSION = YES; 1208 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 1209 | CLANG_WARN_EMPTY_BODY = YES; 1210 | CLANG_WARN_ENUM_CONVERSION = YES; 1211 | CLANG_WARN_INT_CONVERSION = YES; 1212 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 1213 | CLANG_WARN_UNREACHABLE_CODE = YES; 1214 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 1215 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 1216 | COPY_PHASE_STRIP = YES; 1217 | ENABLE_NS_ASSERTIONS = NO; 1218 | ENABLE_STRICT_OBJC_MSGSEND = YES; 1219 | GCC_C_LANGUAGE_STANDARD = gnu99; 1220 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 1221 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 1222 | GCC_WARN_UNDECLARED_SELECTOR = YES; 1223 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 1224 | GCC_WARN_UNUSED_FUNCTION = YES; 1225 | GCC_WARN_UNUSED_VARIABLE = YES; 1226 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 1227 | MTL_ENABLE_DEBUG_INFO = NO; 1228 | SDKROOT = iphoneos; 1229 | VALIDATE_PRODUCT = YES; 1230 | }; 1231 | name = Release; 1232 | }; 1233 | /* End XCBuildConfiguration section */ 1234 | 1235 | /* Begin XCConfigurationList section */ 1236 | 00E357021AD99517003FC87E /* Build configuration list for PBXNativeTarget "SimpleExampleTests" */ = { 1237 | isa = XCConfigurationList; 1238 | buildConfigurations = ( 1239 | 00E356F61AD99517003FC87E /* Debug */, 1240 | 00E356F71AD99517003FC87E /* Release */, 1241 | ); 1242 | defaultConfigurationIsVisible = 0; 1243 | defaultConfigurationName = Release; 1244 | }; 1245 | 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "SimpleExample" */ = { 1246 | isa = XCConfigurationList; 1247 | buildConfigurations = ( 1248 | 13B07F941A680F5B00A75B9A /* Debug */, 1249 | 13B07F951A680F5B00A75B9A /* Release */, 1250 | ); 1251 | defaultConfigurationIsVisible = 0; 1252 | defaultConfigurationName = Release; 1253 | }; 1254 | 2D02E4BA1E0B4A5E006451C7 /* Build configuration list for PBXNativeTarget "SimpleExample-tvOS" */ = { 1255 | isa = XCConfigurationList; 1256 | buildConfigurations = ( 1257 | 2D02E4971E0B4A5E006451C7 /* Debug */, 1258 | 2D02E4981E0B4A5E006451C7 /* Release */, 1259 | ); 1260 | defaultConfigurationIsVisible = 0; 1261 | defaultConfigurationName = Release; 1262 | }; 1263 | 2D02E4BB1E0B4A5E006451C7 /* Build configuration list for PBXNativeTarget "SimpleExample-tvOSTests" */ = { 1264 | isa = XCConfigurationList; 1265 | buildConfigurations = ( 1266 | 2D02E4991E0B4A5E006451C7 /* Debug */, 1267 | 2D02E49A1E0B4A5E006451C7 /* Release */, 1268 | ); 1269 | defaultConfigurationIsVisible = 0; 1270 | defaultConfigurationName = Release; 1271 | }; 1272 | 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "SimpleExample" */ = { 1273 | isa = XCConfigurationList; 1274 | buildConfigurations = ( 1275 | 83CBBA201A601CBA00E9B192 /* Debug */, 1276 | 83CBBA211A601CBA00E9B192 /* Release */, 1277 | ); 1278 | defaultConfigurationIsVisible = 0; 1279 | defaultConfigurationName = Release; 1280 | }; 1281 | /* End XCConfigurationList section */ 1282 | }; 1283 | rootObject = 83CBB9F71A601CBA00E9B192 /* Project object */; 1284 | } 1285 | -------------------------------------------------------------------------------- /examples/SimpleExample/ios/SimpleExample.xcodeproj/xcshareddata/xcschemes/SimpleExample-tvOS.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 43 | 49 | 50 | 51 | 52 | 53 | 58 | 59 | 61 | 67 | 68 | 69 | 70 | 71 | 77 | 78 | 79 | 80 | 81 | 82 | 92 | 94 | 100 | 101 | 102 | 103 | 104 | 105 | 111 | 113 | 119 | 120 | 121 | 122 | 124 | 125 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /examples/SimpleExample/ios/SimpleExample.xcodeproj/xcshareddata/xcschemes/SimpleExample.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 43 | 49 | 50 | 51 | 52 | 53 | 58 | 59 | 61 | 67 | 68 | 69 | 70 | 71 | 77 | 78 | 79 | 80 | 81 | 82 | 92 | 94 | 100 | 101 | 102 | 103 | 104 | 105 | 111 | 113 | 119 | 120 | 121 | 122 | 124 | 125 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /examples/SimpleExample/ios/SimpleExample/AppDelegate.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | @interface AppDelegate : UIResponder 13 | 14 | @property (nonatomic, strong) UIWindow *window; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /examples/SimpleExample/ios/SimpleExample/AppDelegate.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import "AppDelegate.h" 11 | 12 | #import 13 | #import 14 | 15 | @implementation AppDelegate 16 | 17 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 18 | { 19 | NSURL *jsCodeLocation; 20 | 21 | jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil]; 22 | 23 | RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation 24 | moduleName:@"SimpleExample" 25 | initialProperties:nil 26 | launchOptions:launchOptions]; 27 | rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; 28 | 29 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 30 | UIViewController *rootViewController = [UIViewController new]; 31 | rootViewController.view = rootView; 32 | self.window.rootViewController = rootViewController; 33 | [self.window makeKeyAndVisible]; 34 | return YES; 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /examples/SimpleExample/ios/SimpleExample/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 21 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /examples/SimpleExample/ios/SimpleExample/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /examples/SimpleExample/ios/SimpleExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | SimpleExample 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UIViewControllerBasedStatusBarAppearance 40 | 41 | NSLocationWhenInUseUsageDescription 42 | 43 | NSAppTransportSecurity 44 | 45 | 46 | NSExceptionDomains 47 | 48 | localhost 49 | 50 | NSExceptionAllowsInsecureHTTPLoads 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /examples/SimpleExample/ios/SimpleExample/main.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | #import "AppDelegate.h" 13 | 14 | int main(int argc, char * argv[]) { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /examples/SimpleExample/ios/SimpleExampleTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /examples/SimpleExample/ios/SimpleExampleTests/SimpleExampleTests.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | #import 12 | 13 | #import 14 | #import 15 | 16 | #define TIMEOUT_SECONDS 600 17 | #define TEXT_TO_LOOK_FOR @"Welcome to React Native!" 18 | 19 | @interface SimpleExampleTests : XCTestCase 20 | 21 | @end 22 | 23 | @implementation SimpleExampleTests 24 | 25 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test 26 | { 27 | if (test(view)) { 28 | return YES; 29 | } 30 | for (UIView *subview in [view subviews]) { 31 | if ([self findSubviewInView:subview matching:test]) { 32 | return YES; 33 | } 34 | } 35 | return NO; 36 | } 37 | 38 | - (void)testRendersWelcomeScreen 39 | { 40 | UIViewController *vc = [[[RCTSharedApplication() delegate] window] rootViewController]; 41 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; 42 | BOOL foundElement = NO; 43 | 44 | __block NSString *redboxError = nil; 45 | RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { 46 | if (level >= RCTLogLevelError) { 47 | redboxError = message; 48 | } 49 | }); 50 | 51 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) { 52 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 53 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 54 | 55 | foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) { 56 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) { 57 | return YES; 58 | } 59 | return NO; 60 | }]; 61 | } 62 | 63 | RCTSetLogFunction(RCTDefaultLogFunction); 64 | 65 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError); 66 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS); 67 | } 68 | 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /examples/SimpleExample/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "SimpleExample", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "start": "node node_modules/react-native/local-cli/cli.js start", 7 | "test": "jest" 8 | }, 9 | "dependencies": { 10 | "react": "16.0.0-alpha.12", 11 | "react-native": "0.48.4", 12 | "react-native-persistent-job": "^2.3.4" 13 | }, 14 | "devDependencies": { 15 | "babel-jest": "21.0.2", 16 | "babel-preset-react-native": "4.0.0", 17 | "jest": "21.1.0", 18 | "react-test-renderer": "16.0.0-alpha.12" 19 | }, 20 | "jest": { 21 | "preset": "react-native" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /jest.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "roots": ["/tests"], 3 | "moduleNameMapper": { 4 | "\\.(jpg|jpeg|png|svg)$": "/tests/unit/jest/fileMock.js" 5 | }, 6 | "transform": { 7 | "^.+\\.tsx?$": "ts-jest", 8 | "^.+\\.jsx?$": "/node_modules/babel-jest" 9 | }, 10 | "testRegex": "(/tests/.*\\.spec)\\.ts", 11 | "moduleFileExtensions": [ 12 | "ts", 13 | "js", 14 | "json", 15 | "node" 16 | ], 17 | "globals": { 18 | "ts-jest": { 19 | "useBabelrc": true, 20 | "tsConfigFile": "./tsconfig.json" 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-persistent-job", 3 | "version": "2.7.3", 4 | "repository": "https://github.com/GabiNir/react-native-persistent-job", 5 | "description": "", 6 | "main": "./lib/index.js", 7 | "typings": "./lib/index.d.ts", 8 | "scripts": { 9 | "test": "jest --config jest.config.json", 10 | "build": "tsc -p tsconfig.json" 11 | }, 12 | "keywords": [ 13 | "javascript", 14 | "react-native", 15 | "storage" 16 | ], 17 | "author": "Gabi Nir ", 18 | "license": "MIT", 19 | "dependencies": { 20 | "rxjs": "^5.4.2", 21 | "tslib": "^1.7.1", 22 | "uuid": "^3.1.0" 23 | }, 24 | "devDependencies": { 25 | "@types/jest": "^22.2.3", 26 | "@types/react-native": "^0.46.7", 27 | "babel-polyfill": "^6.26.0", 28 | "babel-preset-es2015": "^6.24.1", 29 | "babel-preset-es2017": "^6.24.1", 30 | "babel-preset-react": "^6.24.1", 31 | "babel-preset-stage-2": "^6.24.1", 32 | "jest": "^20.0.4", 33 | "regenerator-runtime": "^0.11.1", 34 | "ts-jest": "^22.4.6", 35 | "typescript": "^2.4.2" 36 | }, 37 | "peerDependencies": { 38 | "react-native": ">= 0.36.0" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import {Subject} from 'rxjs' 2 | import {AsyncStorage} from 'react-native' 3 | import {PersistentJobClient as _PersistentJobClient, PersistentJobClientType} from './persistentJobClient' 4 | import _transformAsyncStorage from './utils/transformAsyncStorage' 5 | import {JobNumbered, JobHandler} from './jobTypes' 6 | import * as _streamModifiers from './streamModifiers' 7 | import * as _jobHandlerModifiers from './jobHandlerModifiers' 8 | export const transformAsyncStorage = _transformAsyncStorage 9 | export const PersistentJobClient = _PersistentJobClient 10 | export const streamModifiers = _streamModifiers 11 | export const jobHandlerModifiers = _jobHandlerModifiers 12 | 13 | type Params = { 14 | storeName?: string, 15 | jobHandlers: JobHandler[], 16 | modifyJobStream?: (jobSubject: Subject) => Subject, 17 | modifyRetryStream?: (retrySubject: Subject) => Subject, 18 | concurrencyLimit?: number, 19 | } 20 | 21 | const storesMap = new Map() 22 | 23 | export default { 24 | async initializeStore({storeName, jobHandlers, modifyJobStream, modifyRetryStream, concurrencyLimit}: Params): Promise { 25 | const storeNameWithDefault = storeName || 'default' 26 | const client = await PersistentJobClient( 27 | storeNameWithDefault, 28 | jobHandlers, 29 | transformAsyncStorage(AsyncStorage), 30 | modifyJobStream, 31 | modifyRetryStream, 32 | concurrencyLimit 33 | ) 34 | 35 | storesMap.set(storeNameWithDefault, client) 36 | 37 | return client 38 | }, 39 | store(storeName?: string): PersistentJobClientType { 40 | const storeNameWithDefault = storeName || 'default' 41 | 42 | if (!storesMap.has(storeNameWithDefault)) { 43 | throw `Store ${storeNameWithDefault} is not initialized. call initializeStore({storeName?: string, jobHandlers: JobHandler[], asyncStorage: AsyncStorageStatic})` 44 | } 45 | 46 | return storesMap.get(storeNameWithDefault) 47 | } 48 | } -------------------------------------------------------------------------------- /src/jobHandlerModifiers/index.ts: -------------------------------------------------------------------------------- 1 | import _limitJobRuns from './limitJobRuns' 2 | export const limitJobRuns = _limitJobRuns -------------------------------------------------------------------------------- /src/jobHandlerModifiers/limitJobRuns.ts: -------------------------------------------------------------------------------- 1 | import { 2 | HandleFunctionStateful, 3 | HandleFuncitonStateless, 4 | JobHandler, 5 | JobHandlerStateful, 6 | } from "../jobTypes" 7 | 8 | const makeStateful = (statelessFunction: HandleFuncitonStateless) => () => (...args) => statelessFunction(...args) 9 | 10 | const withMaxRetries = (maxRetries: number) => 11 | (statefulFunction: HandleFunctionStateful): HandleFunctionStateful => 12 | (currentState, updateState) => 13 | async (...args) => { 14 | const state = currentState || {retryCount: 0} 15 | const retryCount = state.retryCount || 0 16 | if (retryCount >= maxRetries) return; 17 | 18 | const updateStateWithRetries = state => updateState({...state, retryCount}) 19 | const {retryCount: _, ...stateWithoutRetries} = state 20 | 21 | try { 22 | return await statefulFunction(stateWithoutRetries, updateStateWithRetries)(...args) 23 | } catch (e) { 24 | await updateState({...state, retryCount: retryCount + 1}) 25 | throw e 26 | } 27 | } 28 | 29 | export default (maxRetries: number) => (handler: JobHandler): JobHandlerStateful => { 30 | if (handler.isStateful) { 31 | return { 32 | ...handler, 33 | handleFunction: withMaxRetries(maxRetries)(handler.handleFunction) 34 | } 35 | } else { 36 | return { 37 | ...handler, 38 | isStateful: true, 39 | handleFunction: withMaxRetries(maxRetries)(makeStateful(handler.handleFunction)) 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /src/jobPersistence.ts: -------------------------------------------------------------------------------- 1 | import {Job, JobNumbered} from './jobTypes' 2 | 3 | type PersistedJob = JobNumbered & { 4 | isDone: boolean 5 | } 6 | 7 | const prefix = "@react-native-persisted-job" 8 | 9 | export type AsyncStorage = { 10 | setItem: (key: string, item: any) => Promise, 11 | getItem: (key: string) => Promise, 12 | removeItem: (key: string) => Promise, 13 | multiRemove: (key: Array) => Promise, 14 | multiSet: (pairs: Array<{key: string, value: T}>) => Promise 15 | } 16 | 17 | export type JobPersisterType = { 18 | persistNewJob: (job: Job) => Promise, 19 | updateJob: (job: JobNumbered) => Promise, 20 | clearPersistedJob: (job: JobNumbered) => Promise, 21 | fetchAllPersistedJobs: () => Promise>, 22 | clearDoneJobsFromStore: () => Promise, 23 | } 24 | 25 | export async function JobPersister ( 26 | storeName: string, 27 | asyncStorage: AsyncStorage 28 | ): Promise { 29 | const serialNumberKey = `${prefix}:${storeName}:currentSerialNumber` 30 | let currentSerialNumber = await asyncStorage.getItem(serialNumberKey) || 0 31 | const stripPersistentFields = (job: JobNumbered) => ({ 32 | id: job.id, 33 | args: job.args, 34 | jobType: job.jobType, 35 | serialNumber: job.serialNumber, 36 | timestamp: job.timestamp, 37 | state: job.state, 38 | extraPersistentData: job.extraPersistentData, 39 | }) 40 | const getJobKey = (serialNumber: number) => `${prefix}:${storeName}:${serialNumber}` 41 | 42 | // public 43 | async function persistNewJob(job: Job): Promise { 44 | currentSerialNumber++ 45 | const serialNumber = currentSerialNumber 46 | const jobNumbered: JobNumbered = {...job, serialNumber} 47 | 48 | await asyncStorage.setItem(serialNumberKey, currentSerialNumber) 49 | await asyncStorage.setItem(getJobKey(serialNumber), {...stripPersistentFields(jobNumbered), isDone: false}) 50 | 51 | return jobNumbered 52 | } 53 | 54 | // public 55 | async function updateJob(job: JobNumbered): Promise { 56 | await asyncStorage.setItem(getJobKey(job.serialNumber), {...stripPersistentFields(job), isDone: false}) 57 | } 58 | 59 | // public 60 | async function clearPersistedJob(job: JobNumbered): Promise { 61 | await asyncStorage.setItem(getJobKey(job.serialNumber), {...job, isDone: true}) 62 | } 63 | 64 | // public 65 | async function fetchAllPersistedJobs(): Promise> { 66 | const persistedJobs: Array = [] 67 | 68 | for (let i = 1; i <= currentSerialNumber; i++) { 69 | persistedJobs.push(await asyncStorage.getItem(getJobKey(i))) 70 | } 71 | 72 | return persistedJobs 73 | } 74 | 75 | // public 76 | async function clearDoneJobsFromStore(): Promise { 77 | const allJobs = await fetchAllPersistedJobs() 78 | const jobsInProgress: Array = allJobs.filter(job => job && !job.isDone).map((job, i) => ({...job, serialNumber: i+1})) 79 | 80 | const itemsToRemove: Array = [] 81 | for (let i = jobsInProgress.length + 1; i <= currentSerialNumber; i++) { 82 | itemsToRemove.push(getJobKey(i)) 83 | } 84 | 85 | const itemsToUpdate = jobsInProgress.map(job => ({key: getJobKey(job.serialNumber), value: job})) 86 | currentSerialNumber = jobsInProgress.length 87 | 88 | await Promise.all([ 89 | asyncStorage.multiSet(itemsToUpdate), 90 | asyncStorage.multiRemove(itemsToRemove), 91 | asyncStorage.setItem(serialNumberKey, currentSerialNumber) 92 | ]) 93 | } 94 | 95 | return { 96 | persistNewJob, 97 | updateJob, 98 | clearPersistedJob, 99 | fetchAllPersistedJobs, 100 | clearDoneJobsFromStore, 101 | } 102 | } -------------------------------------------------------------------------------- /src/jobRunner.ts: -------------------------------------------------------------------------------- 1 | import {Subject, Observable} from 'rxjs' 2 | import {Job, JobNumbered, JobHandler} from './jobTypes' 3 | import {JobPersisterType} from './jobPersistence' 4 | import {JobSubscriptions, JobSubscription, RemoveSubscription} from './jobSubscriptions' 5 | import * as uuid from 'uuid' 6 | 7 | export type JobRunnerType = { 8 | createJob: (jobType: string, topic?: string) => (...args: Array) => Promise, 9 | subscribe: (jobId: string, subscription: JobSubscription) => RemoveSubscription, 10 | } 11 | 12 | export function JobRunner ( 13 | jobHandlersMap: Map, 14 | jobPersister: JobPersisterType, 15 | initialJobs?: Array, 16 | modifyJobSubject?: (jobSubject: Observable) => Observable, 17 | modifyRetrySubject?: (retrySubject: Observable) => Observable, 18 | limitConccurency?: number, 19 | ) { 20 | const jobSubject = new Subject() 21 | const job$ = Observable 22 | .concat(Observable.from(initialJobs || []), jobSubject.asObservable()) 23 | .do(job => job.topic && jobSubscriptions.addTopic(job.topic, job)) 24 | const modifiedJob$ = modifyJobSubject? modifyJobSubject(job$) : job$ 25 | const retrySubject = new Subject() 26 | const retry$ = modifyRetrySubject ? modifyRetrySubject(retrySubject.asObservable()) : retrySubject.asObservable() 27 | const jobSubscriptions = JobSubscriptions() 28 | 29 | const addJob = (job: JobNumbered) => jobSubject.next(job) 30 | const addRetry = (job: JobNumbered) => retrySubject.next(job) 31 | 32 | async function jobObserver(job: JobNumbered) { 33 | const jobHandler = jobHandlersMap.get(job.jobType) 34 | 35 | if (!jobHandler) throw `Tried to invoke job of type ${job.jobType} which does not exist`; 36 | 37 | const updateState = async (state: any) => { 38 | job.state = state 39 | await jobPersister.updateJob(job) 40 | 41 | if (job.topic) jobSubscriptions.notifySubscriptions(job.topic, {jobState: 'JOB_INTERMEDIATE', value: job.state}) 42 | } 43 | 44 | try { 45 | const value = jobHandler.isStateful 46 | ? await jobHandler.handleFunction(job.state, updateState)(...job.args) 47 | : await jobHandler.handleFunction(...job.args) 48 | 49 | await jobPersister.clearPersistedJob(job) 50 | 51 | if (job.topic) jobSubscriptions.notifySubscriptions(job.topic, {jobState: 'JOB_DONE', value}) 52 | if (job.topic) jobSubscriptions.removeTopic(job.topic) 53 | } catch (e) { 54 | if (job.topic) jobSubscriptions.notifySubscriptions(job.topic, {jobState: 'JOB_FAILED', value: e}) 55 | addRetry(job) 56 | } 57 | } 58 | 59 | modifiedJob$ 60 | .flatMap( 61 | job => Observable.fromPromise(jobObserver(job)), 62 | limitConccurency 63 | ) 64 | .subscribe() 65 | retry$.subscribe(job => addJob({...job, id: uuid.v4()})) 66 | 67 | // public 68 | const createJob = (jobType: string, topic?: string) => async (...args: Array) => { 69 | if (!jobHandlersMap.has(jobType)) { 70 | throw `Can not handle a job of type ${jobType} because there is no job handler for it` 71 | } 72 | 73 | const job: Job = {jobType, args, timestamp: Date.now(), id: uuid.v4(), topic} 74 | if (topic) { 75 | jobSubscriptions.addTopic(topic, job) 76 | } 77 | 78 | const jobNumbered: JobNumbered = await jobPersister.persistNewJob(job) 79 | addJob(jobNumbered) 80 | } 81 | 82 | return { 83 | createJob, 84 | subscribe: jobSubscriptions.addSubscription, 85 | } 86 | } -------------------------------------------------------------------------------- /src/jobSubscriptions.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Job, 3 | } from './jobTypes' 4 | 5 | export type JobSubscription = (jobState: any) => void 6 | export type RemoveSubscription = () => void 7 | 8 | type JobSubscriptionNotification = { 9 | jobState: 'JOB_STARTED' | 'JOB_DONE' | 'JOB_NOT_FOUND' | 'JOB_INTERMEDIATE' | 'JOB_FAILED', 10 | value?: any 11 | } 12 | 13 | export function JobSubscriptions() { 14 | const topics: {[topic: string]: Job} = {} 15 | const subscriptions: {[topic: string]: Set} = {} 16 | 17 | // public 18 | function addTopic(topic: string, job: Job): void { 19 | topics[topic] = job 20 | } 21 | 22 | // public 23 | function addSubscription(topic: string, subscription: JobSubscription): RemoveSubscription { 24 | if (subscriptions[topic]) { 25 | subscriptions[topic].add(subscription) 26 | } else { 27 | subscriptions[topic] = new Set([subscription]) 28 | } 29 | 30 | const job = topics[topic] 31 | 32 | if (job) { 33 | if (job.state) { 34 | subscription({jobState: 'JOB_INTERMEDIATE', value: job.state}) 35 | } else { 36 | subscription({jobState: 'JOB_STARTED'}) 37 | } 38 | } else { 39 | subscription({jobState: 'JOB_NOT_FOUND'}) 40 | } 41 | 42 | return () => subscriptions[topic] && subscriptions[topic].delete(subscription) 43 | } 44 | 45 | // public 46 | function notifySubscriptions(topic: string, notification: JobSubscriptionNotification): void { 47 | subscriptions[topic].forEach(subscription => subscription(notification)) 48 | } 49 | 50 | // public 51 | function removeTopic(topic: string): void { 52 | delete subscriptions[topic] 53 | delete topics[topic] 54 | } 55 | 56 | return { 57 | addSubscription, 58 | notifySubscriptions, 59 | removeTopic, 60 | addTopic, 61 | } 62 | } -------------------------------------------------------------------------------- /src/jobTypes.ts: -------------------------------------------------------------------------------- 1 | export type Job = { 2 | jobType: string, 3 | args: any[], 4 | timestamp: number, 5 | id: string, 6 | state?: any, 7 | topic?: string, 8 | terminated?: boolean, 9 | extraPersistentData?: {}, 10 | } 11 | 12 | export type JobNumbered = Job & { 13 | serialNumber: number, 14 | } 15 | 16 | type UpdateState = (state: any) => Promise 17 | export type HandleFunctionStateful = (currentState: any, updateState: UpdateState) => (...args: any[]) => Promise 18 | export type HandleFuncitonStateless = (...args: any[]) => Promise 19 | 20 | export type JobHandlerStateful = { 21 | isStateful: true, 22 | jobType: string, 23 | handleFunction: HandleFunctionStateful, 24 | } 25 | 26 | export type JobHandlerStateless = { 27 | isStateful?: false, 28 | jobType: string, 29 | handleFunction: HandleFuncitonStateless, 30 | } 31 | 32 | export type JobHandler = JobHandlerStateful | JobHandlerStateless -------------------------------------------------------------------------------- /src/persistentJobClient.ts: -------------------------------------------------------------------------------- 1 | import {Observable} from 'rxjs' 2 | import {JobNumbered, JobHandler} from './jobTypes' 3 | import {JobRunner, JobRunnerType} from './jobRunner' 4 | import {JobPersister, AsyncStorage} from './jobPersistence' 5 | 6 | 7 | export type PersistentJobClientType = JobRunnerType 8 | export async function PersistentJobClient ( 9 | storeName: string, 10 | jobHandlers: Array, 11 | asyncStorage: AsyncStorage, 12 | modifyJobSubject?: (jobSubject: Observable) => Observable, 13 | modifyRetrySubject?: (retrySubject: Observable) => Observable, 14 | limitConccurency?: number, 15 | ): Promise { 16 | const jobPersister = await JobPersister(storeName, asyncStorage) 17 | const jobHandlersMap = new Map() 18 | jobHandlers.forEach(jobHandler => jobHandlersMap.set(jobHandler.jobType, jobHandler)) 19 | await jobPersister.clearDoneJobsFromStore() 20 | const persistedJobs = await jobPersister.fetchAllPersistedJobs() 21 | const jobRunner = JobRunner(jobHandlersMap, jobPersister, persistedJobs, modifyJobSubject, modifyRetrySubject, limitConccurency) 22 | 23 | return { 24 | ...jobRunner, 25 | } 26 | } 27 | 28 | -------------------------------------------------------------------------------- /src/streamModifiers/index.ts: -------------------------------------------------------------------------------- 1 | import {NetInfo} from 'react-native' 2 | import _runWhenOnline from './runWhenOnline' 3 | import * as _retryStream from './retryStream' 4 | import {StreamModifier} from './types' 5 | 6 | export const runWhenOnline = _runWhenOnline(NetInfo) 7 | export const retryStream = _retryStream 8 | export const compose = (...streamModifiers: StreamModifier[]): StreamModifier => { 9 | return (originalObservable) => streamModifiers.reduce( 10 | (composedObservable, current) => current(composedObservable), 11 | originalObservable 12 | ) 13 | } -------------------------------------------------------------------------------- /src/streamModifiers/retryStream/index.ts: -------------------------------------------------------------------------------- 1 | import _withBackoff from './withBackoff' 2 | import _noRetries from './noRetries' 3 | 4 | export const withBackoff = _withBackoff 5 | export const noRetries = _noRetries -------------------------------------------------------------------------------- /src/streamModifiers/retryStream/noRetries.ts: -------------------------------------------------------------------------------- 1 | import {Observable} from 'rxjs' 2 | import {JobNumbered} from '../../jobTypes' 3 | 4 | export default (obs: Observable) => obs.filter(_ => false) -------------------------------------------------------------------------------- /src/streamModifiers/retryStream/withBackoff.ts: -------------------------------------------------------------------------------- 1 | import {Observable} from 'rxjs' 2 | import {JobNumbered} from '../../jobTypes' 3 | 4 | type JobWithRetries = JobNumbered & { retryNumber?: number} 5 | type BackoffMethod = (retryNumber: number) => number 6 | 7 | const waitedJob = (job: JobWithRetries, timeToWait: number) => new Promise(res => setTimeout(() => res(job), timeToWait)) 8 | const backoffStream = (backoffMethod: BackoffMethod) => (subject: Observable) => { 9 | return subject 10 | .map(job => { 11 | const jobWithRetries = job 12 | 13 | return jobWithRetries.retryNumber 14 | ? {...jobWithRetries, retryNumber: jobWithRetries.retryNumber + 1} 15 | : {...jobWithRetries, retryNumber: 1} 16 | }) 17 | .flatMap(async job => waitedJob(job, backoffMethod(job.retryNumber - 1))) 18 | } 19 | 20 | const exponentialBackoffMethod = (initialWaitTime: number, maxWaitTime?: number) => (retryNumber: number) => { 21 | const waitTime = initialWaitTime * Math.pow(2, retryNumber) 22 | 23 | return maxWaitTime && maxWaitTime < waitTime 24 | ? maxWaitTime 25 | : waitTime 26 | } 27 | 28 | const fibonacci = (index: number): number => { 29 | if (index === 0) return 1 30 | if (index === 1) return 1 31 | 32 | return fibonacci(index - 1) + fibonacci(index - 2) 33 | } 34 | 35 | const fibonacciBackoffMethod = (initialWaitTime: number, maxWaitTime?: number) => (retryNumber: number) => { 36 | const waitTime = initialWaitTime * fibonacci(retryNumber + 1) 37 | 38 | return maxWaitTime && maxWaitTime < waitTime 39 | ? maxWaitTime 40 | : waitTime 41 | } 42 | 43 | const withBackoff = { 44 | exponential: (initialWaitTime: number, maxWaitTime?: number) => backoffStream(exponentialBackoffMethod(initialWaitTime, maxWaitTime)), 45 | fibonacci: (initialWaitTime: number, maxWaitTime?: number) => backoffStream(fibonacciBackoffMethod(initialWaitTime, maxWaitTime)) 46 | } 47 | 48 | export default withBackoff -------------------------------------------------------------------------------- /src/streamModifiers/runWhenOnline.ts: -------------------------------------------------------------------------------- 1 | import { NetInfo } from 'react-native' 2 | import { Observable } from 'rxjs' 3 | import { JobNumbered } from '../jobTypes' 4 | 5 | const runWhenOnline = (netInfo: NetInfo) => (subject: Observable) => { 6 | const netInfoObservable: Observable = Observable.fromEventPattern(h => netInfo.isConnected.addEventListener('connectionChange', <(r: boolean) => void>h)) 7 | const connectivityObservable: Observable = Observable.merge( 8 | Observable.fromPromise(netInfo.isConnected.fetch()), 9 | netInfoObservable 10 | ) 11 | 12 | const obs = Observable 13 | .combineLatest(subject, connectivityObservable, (job, isConnected) => ({ job, isConnected })) 14 | .flatMap( 15 | ({ job, isConnected }) => 16 | isConnected ? 17 | Observable.of(job) : 18 | netInfoObservable.filter(connectionIsBack => connectionIsBack).first().map(_ => job) 19 | ) 20 | .distinct(job => job.id) 21 | 22 | return obs 23 | } 24 | 25 | export default runWhenOnline -------------------------------------------------------------------------------- /src/streamModifiers/types.ts: -------------------------------------------------------------------------------- 1 | import {Observable} from 'rxjs' 2 | import {JobNumbered} from '../jobTypes' 3 | 4 | export type StreamModifier = (subject: Observable) => Observable -------------------------------------------------------------------------------- /src/utils/transformAsyncStorage.ts: -------------------------------------------------------------------------------- 1 | import {AsyncStorage} from '../jobPersistence' 2 | import {AsyncStorage as AsyncStorageReactNative} from 'react-native' 3 | 4 | export default ( 5 | asyncStorage: AsyncStorageReactNative 6 | ): AsyncStorage => { 7 | 8 | const serializeItem = (item: any) => { 9 | if (typeof item === 'object') { 10 | return JSON.stringify(item) 11 | } else { 12 | return item + '' 13 | } 14 | } 15 | 16 | // public 17 | async function getItem(key: string) { 18 | const serializedData = await asyncStorage.getItem(key) 19 | try { 20 | return JSON.parse(serializedData) 21 | } catch (e) { 22 | return parseInt(serializedData) || serializedData 23 | } 24 | } 25 | 26 | // public 27 | async function setItem(key: string, value: any) { 28 | asyncStorage.setItem(key, serializeItem(value)) 29 | } 30 | 31 | // public 32 | async function multiSet(keyValuePairs: {key: string, value: any}[]) { 33 | if (keyValuePairs.length === 0) return; 34 | const pairsAsArray = keyValuePairs.map(({key, value}) => [key, serializeItem(value)]) 35 | await asyncStorage.multiSet(pairsAsArray) 36 | } 37 | 38 | // public 39 | async function multiRemove(keys: string[]) { 40 | if (keys.length === 0) return; 41 | await asyncStorage.multiRemove(keys) 42 | } 43 | 44 | return { 45 | removeItem: asyncStorage.removeItem, 46 | multiRemove, 47 | getItem, 48 | setItem, 49 | multiSet 50 | } 51 | } -------------------------------------------------------------------------------- /tests/asyncStorage.ts: -------------------------------------------------------------------------------- 1 | export default obj => { 2 | 3 | // public 4 | async function getItem(key) { 5 | return obj[key] 6 | } 7 | 8 | // public 9 | async function setItem(key, item) { 10 | obj[key] = item 11 | } 12 | 13 | // public 14 | async function removeItem(key) { 15 | obj[key] = undefined 16 | } 17 | 18 | // public 19 | async function multiRemove(keys) { 20 | keys.forEach(key => removeItem(key)) 21 | } 22 | 23 | // public 24 | async function multiSet(keyValuePairs) { 25 | keyValuePairs.forEach(pair => setItem(pair.key, pair.value)) 26 | } 27 | 28 | //public 29 | function getCachedItem(key) { 30 | return obj[key] 31 | } 32 | 33 | return { 34 | getItem, 35 | setItem, 36 | removeItem, 37 | multiRemove, 38 | multiSet, 39 | getCachedItem, 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /tests/jobHandlerModifiers/limitJobRuns.spec.ts: -------------------------------------------------------------------------------- 1 | import 'babel-polyfill'; 2 | import {PersistentJobClient} from '../../src/persistentJobClient' 3 | import AsyncStorage from '../asyncStorage' 4 | import limitJobRuns from '../../src/jobHandlerModifiers/limitJobRuns' 5 | 6 | const EMPTY_STATE = {} 7 | const sleep = time => new Promise(res => setTimeout(res, time * 4)) 8 | 9 | describe('limitJobRuns works correctly', () => { 10 | it('After all retries are done job should not run', async () => { 11 | const spy = jest.fn() 12 | const RUNS_LIMIT = 3 13 | const handleFunction = async () => { 14 | await sleep(1) 15 | spy() 16 | throw 'bad' 17 | } 18 | 19 | const client = await PersistentJobClient( 20 | "After all retries are done job should not run", 21 | [ 22 | limitJobRuns(RUNS_LIMIT)( 23 | {jobType: 'fail', handleFunction} 24 | ) 25 | ], 26 | AsyncStorage(EMPTY_STATE) 27 | ) 28 | 29 | client.createJob('fail')() 30 | await sleep(20) 31 | 32 | expect(spy.mock.calls.length).toBe(RUNS_LIMIT) 33 | }) 34 | }) -------------------------------------------------------------------------------- /tests/jobStorageState.ts: -------------------------------------------------------------------------------- 1 | const prefix = "@react-native-persisted-job" 2 | 3 | export const JobStorageStateManager = (storeName) => { 4 | function getJobKey(serialNumber) { 5 | return `${prefix}:${storeName}:${serialNumber}` 6 | } 7 | 8 | const serialNumberKey = `${prefix}:${storeName}:currentSerialNumber` 9 | 10 | let currentSerialNumber = 0 11 | const state = {} 12 | const simulateAddJob = (job) => { 13 | currentSerialNumber++ 14 | const jobNumbered = {...job, serialNumber: currentSerialNumber} 15 | 16 | state[serialNumberKey] = currentSerialNumber 17 | state[getJobKey(currentSerialNumber)] = {...jobNumbered, isDone: false} 18 | } 19 | 20 | const simulateJobFinish = (serialNumber) => { 21 | state[getJobKey(serialNumber)].isDone = true 22 | } 23 | 24 | return { 25 | simulateAddJob, 26 | simulateJobFinish, 27 | state 28 | } 29 | } -------------------------------------------------------------------------------- /tests/persistentJobClient.spec.ts: -------------------------------------------------------------------------------- 1 | import 'babel-polyfill'; 2 | import {PersistentJobClient} from '../src/persistentJobClient' 3 | import noRetries from '../src/streamModifiers/retryStream/noRetries' 4 | import AsyncStorage from './asyncStorage' 5 | import {JobStorageStateManager} from './jobStorageState' 6 | import uuid from 'uuid' 7 | 8 | const EMPTY_STATE = {} 9 | const SPY_JOB = 'SPY_JOB' 10 | const spy = async (callMe) => { 11 | callMe.call() 12 | } 13 | 14 | const createCallMe = () => { 15 | let isCalled = {value: false} 16 | const call = () => isCalled.value = true 17 | 18 | return { 19 | isCalled: () => isCalled.value, 20 | call 21 | } 22 | } 23 | 24 | const Job = (jobType) => (...args) => ({ 25 | id: uuid.v4(), 26 | jobType, 27 | args, 28 | timestamp: Date.now() 29 | }) 30 | 31 | const sleep = time => new Promise(res => setTimeout(() => res(), time * 4)) 32 | 33 | const storeName = 'store' 34 | 35 | describe('Jobs run correctly', () => { 36 | it ('On load several done jobs should be deleted', async () => { 37 | const stateManager = JobStorageStateManager(storeName) 38 | const SpyJob = Job(SPY_JOB) 39 | 40 | const shouldNotBeCalled = createCallMe() 41 | for (let i = 1; i <= 6; i++) { 42 | stateManager.simulateAddJob(SpyJob(shouldNotBeCalled)) 43 | stateManager.simulateJobFinish(i) 44 | } 45 | 46 | await PersistentJobClient( 47 | storeName, 48 | [{jobType: SPY_JOB, handleFunction: spy}], 49 | AsyncStorage(stateManager.state) 50 | ) 51 | 52 | await sleep(1) 53 | 54 | expect(shouldNotBeCalled.isCalled()).toBeFalsy() 55 | expect(stateManager.state['@react-native-persisted-job:store:currentSerialNumber']).toBe(0) 56 | 57 | for (let i = 1; i <= 6; i++) { 58 | expect(stateManager.state[`@react-native-persisted-job:store:${i}`]).toBe(undefined) 59 | } 60 | }) 61 | 62 | it('On load done jobs should be deleted, in progress jobs should run', async () => { 63 | const stateManager = JobStorageStateManager(storeName) 64 | const SpyJob = Job(SPY_JOB) 65 | 66 | const shouldBeCalled = createCallMe() 67 | const shouldNotBeCalled = createCallMe() 68 | stateManager.simulateAddJob(SpyJob(shouldBeCalled)) 69 | stateManager.simulateAddJob(SpyJob(shouldNotBeCalled)) 70 | stateManager.simulateJobFinish(2) 71 | 72 | await PersistentJobClient( 73 | storeName, 74 | [{jobType: SPY_JOB, handleFunction: spy}], 75 | AsyncStorage(stateManager.state) 76 | ) 77 | 78 | await sleep(1) 79 | 80 | expect(shouldBeCalled.isCalled()).toBeTruthy() 81 | expect(shouldNotBeCalled.isCalled()).toBeFalsy() 82 | }) 83 | 84 | it('New jobs should run', async () => { 85 | const shouldBeCalled = createCallMe() 86 | 87 | const client = await PersistentJobClient( 88 | storeName, 89 | [{jobType: SPY_JOB, handleFunction: spy}], 90 | AsyncStorage(EMPTY_STATE) 91 | ) 92 | 93 | client.createJob(SPY_JOB)(shouldBeCalled) 94 | 95 | await sleep(1) 96 | 97 | expect(shouldBeCalled.isCalled()).toBeTruthy() 98 | }) 99 | 100 | it('stateful jobs run correctly after failure', async () => { 101 | const spy = jest.fn() 102 | const runAndFail = (currentState, updateState) => async () => { 103 | const curr = currentState || 0 104 | spy(curr) 105 | if (curr < 10) { 106 | await updateState(curr + 1) 107 | 108 | throw 'I failed' 109 | } 110 | } 111 | 112 | const asyncStorage = AsyncStorage(EMPTY_STATE) 113 | const client = await PersistentJobClient( 114 | storeName, 115 | [{jobType: 'runAndFail', handleFunction: runAndFail, isStateful: true}], 116 | asyncStorage, 117 | undefined, 118 | subject => subject.filter(() => false) 119 | ) 120 | 121 | client.createJob('runAndFail')() 122 | 123 | for (let i = 1; i < 10; i++) { 124 | 125 | /* sleep 10 to wait until update state is finished before 126 | restarting the PersistentJobClient because of a race condition that won't happen in real applications */ 127 | await sleep(10) 128 | await PersistentJobClient( 129 | storeName, 130 | [{jobType: 'runAndFail', handleFunction: runAndFail, isStateful: true}], 131 | asyncStorage, 132 | undefined, 133 | 134 | // shut down the retry stream 135 | subject => subject.filter(() => false) 136 | ) 137 | 138 | expect(spy.mock.calls[i][0]).toBe(i) 139 | } 140 | }) 141 | 142 | it('When running several jobs without concurrency limit jobs run concurrently', async () => { 143 | const spy = jest.fn() 144 | const asyncStorage = AsyncStorage(EMPTY_STATE) 145 | const runAndSleep = async () => { 146 | spy(1) 147 | await sleep(20) 148 | } 149 | 150 | const client = await PersistentJobClient( 151 | 'When running several jobs without concurrency limit jobs run concurrently', 152 | [{jobType: 'runAndSleep', handleFunction: runAndSleep}], 153 | asyncStorage, 154 | ) 155 | 156 | const CALL_NUMBER = 100 157 | const persistentRunAndSleep = client.createJob('runAndSleep') 158 | for (let i = 0; i < CALL_NUMBER; i++) { 159 | persistentRunAndSleep() 160 | } 161 | 162 | // Let all jobs run concurrently 163 | await sleep(100) 164 | 165 | expect(spy.mock.calls.length).toBe(CALL_NUMBER) 166 | }) 167 | 168 | it('When running several jobs and concurrency limit is set to 1, run one job at a time', async () => { 169 | const spy = jest.fn() 170 | const asyncStorage = AsyncStorage(EMPTY_STATE) 171 | const runAndSleep = async () => { 172 | spy(1) 173 | await sleep(20) 174 | } 175 | 176 | const client = await PersistentJobClient( 177 | 'When running several jobs and concurrency limit is on jobs run do not run concurrently', 178 | [{jobType: 'runAndSleep', handleFunction: runAndSleep}], 179 | asyncStorage, 180 | undefined, 181 | undefined, 182 | 1 183 | ) 184 | 185 | const CALL_NUMBER = 100 186 | const WAIT_TIME = 100 187 | const persistentRunAndSleep = client.createJob('runAndSleep') 188 | for (let i = 0; i < CALL_NUMBER; i++) { 189 | persistentRunAndSleep() 190 | } 191 | 192 | // Let some jobs run 193 | await sleep(WAIT_TIME) 194 | 195 | expect(spy.mock.calls.length).toBeLessThan(WAIT_TIME / 10) 196 | }) 197 | 198 | it('When running several jobs and concurrency limit is set to 2, run two jobs at a time', async () => { 199 | const spy = jest.fn() 200 | const asyncStorage = AsyncStorage(EMPTY_STATE) 201 | const runAndSleep = async () => { 202 | spy(1) 203 | await sleep(20) 204 | } 205 | 206 | const client = await PersistentJobClient( 207 | 'When running several jobs and concurrency limit is set to 2, run two jobs at a time', 208 | [{jobType: 'runAndSleep', handleFunction: runAndSleep}], 209 | asyncStorage, 210 | undefined, 211 | undefined, 212 | 2 213 | ) 214 | 215 | const CALL_NUMBER = 100 216 | const WAIT_TIME = 100 217 | const persistentRunAndSleep = client.createJob('runAndSleep') 218 | for (let i = 0; i < CALL_NUMBER; i++) { 219 | persistentRunAndSleep() 220 | } 221 | 222 | // Let some jobs run 223 | await sleep(WAIT_TIME) 224 | 225 | expect(spy.mock.calls.length).toBeGreaterThanOrEqual(WAIT_TIME / 10) 226 | expect(spy.mock.calls.length).toBeLessThan(WAIT_TIME * 2 / 10) 227 | }) 228 | }) 229 | 230 | describe("No race conditions on job writes",() => { 231 | const SlowAsyncStorage = (state) => { 232 | const innerAsyncStorage = AsyncStorage(state) 233 | 234 | const setItem = async (key, item) => { 235 | await sleep(20) 236 | await innerAsyncStorage.setItem(key, item) 237 | } 238 | 239 | return { 240 | ...innerAsyncStorage, 241 | setItem, 242 | } 243 | } 244 | it("When writing multiple jobs to async storage they don't override eachother", async () => { 245 | const trackedStorageState = {} 246 | 247 | const client = await PersistentJobClient( 248 | "someStore", 249 | [{jobType: 'nullFunction', handleFunction: ()=>{throw 'noGood'}}], 250 | SlowAsyncStorage(trackedStorageState), 251 | undefined, noRetries 252 | ) 253 | 254 | await Promise.all([client.createJob('nullFunction')(), client.createJob('nullFunction')()]) 255 | 256 | await sleep(60) 257 | 258 | expect(trackedStorageState['@react-native-persisted-job:someStore:currentSerialNumber']).toBe(2) 259 | expect(trackedStorageState['@react-native-persisted-job:someStore:1']).toBeDefined() 260 | expect(trackedStorageState['@react-native-persisted-job:someStore:2']).toBeDefined() 261 | }) 262 | }) 263 | describe("job subscriptions work correctly", () => { 264 | it("When a subscriber subscribes to a job it sees when the job starts and when it ends", async () => { 265 | const spy = jest.fn() 266 | 267 | const client = await PersistentJobClient( 268 | "When a subscriber subscribes to a job it sees when the job starts and when it ends", 269 | [{jobType: 'sleep', handleFunction: () => sleep(10)}], 270 | AsyncStorage(EMPTY_STATE) 271 | ) 272 | 273 | const SOME_TOPIC = 'SOME_TOPIC' 274 | await client.createJob('sleep', SOME_TOPIC)() 275 | client.subscribe(SOME_TOPIC, (state) => spy(state)) 276 | 277 | await sleep(20) 278 | expect(spy.mock.calls[0][0].jobState).toBe('JOB_STARTED') 279 | expect(spy.mock.calls[1][0].jobState).toBe('JOB_DONE') 280 | }) 281 | 282 | it("Stateful jobs should show intermediate state to subscribers", async () => { 283 | const spy = jest.fn() 284 | 285 | const statefulFunction = (_, updateState) => async () => { 286 | for (let i = 0; i < 10; i++) { 287 | await updateState('state' + i) 288 | await sleep(10) 289 | } 290 | } 291 | 292 | const client = await PersistentJobClient( 293 | "Stateful jobs should show intermediate state to subscribers", 294 | [{jobType: 'something', handleFunction: statefulFunction, isStateful: true}], 295 | AsyncStorage(EMPTY_STATE) 296 | ) 297 | 298 | const SOME_TOPIC = 'SOME_TOPIC' 299 | client.createJob('something', SOME_TOPIC)() 300 | client.subscribe(SOME_TOPIC, (state) => spy(state)) 301 | 302 | await sleep(150) 303 | expect(spy.mock.calls[0][0].jobState).toBe('JOB_STARTED') 304 | for (let i = 1; i < 11; i++) { 305 | const {jobState, value} = spy.mock.calls[i][0] 306 | expect(jobState).toBe('JOB_INTERMEDIATE') 307 | expect(value).toBe('state' + (i - 1)) 308 | } 309 | expect(spy.mock.calls[11][0].jobState).toBe('JOB_DONE') 310 | }) 311 | 312 | it("When running several subscribers, each subscriber should be notified", async () => { 313 | const spy = jest.fn() 314 | const spy2 = jest.fn() 315 | const spy3 = jest.fn() 316 | const client = await PersistentJobClient( 317 | "When running several subscribers, each subscriber should be notified", 318 | [{jobType: 'sleep', handleFunction: () => sleep(10)}], 319 | AsyncStorage(EMPTY_STATE) 320 | ) 321 | 322 | const SOME_TOPIC = 'SOME_TOPIC' 323 | await client.createJob('sleep', SOME_TOPIC)() 324 | client.subscribe(SOME_TOPIC, (state) => spy(state)) 325 | client.subscribe(SOME_TOPIC, (state) => spy2(state)) 326 | client.subscribe(SOME_TOPIC, (state) => spy3(state)) 327 | 328 | await sleep(30) 329 | expect(spy.mock.calls[0][0].jobState).toBe('JOB_STARTED') 330 | expect(spy.mock.calls[1][0].jobState).toBe('JOB_DONE') 331 | expect(spy2.mock.calls[0][0].jobState).toBe('JOB_STARTED') 332 | expect(spy2.mock.calls[1][0].jobState).toBe('JOB_DONE') 333 | expect(spy3.mock.calls[0][0].jobState).toBe('JOB_STARTED') 334 | expect(spy3.mock.calls[1][0].jobState).toBe('JOB_DONE') 335 | }) 336 | }) -------------------------------------------------------------------------------- /tests/preprocessor.js: -------------------------------------------------------------------------------- 1 | const tsc = require('typescript'); 2 | const tsConfig = require('../tsconfig.json'); 3 | 4 | module.exports = { 5 | process(src, path) { 6 | if (path.endsWith('.ts') || path.endsWith('.tsx')) { 7 | return tsc.transpile(src, tsConfig.compilerOptions, path, []); 8 | } 9 | return src; 10 | }, 11 | }; 12 | -------------------------------------------------------------------------------- /tests/subjectModifiers/retryStream/withBackoff.spec.ts: -------------------------------------------------------------------------------- 1 | import 'babel-polyfill'; 2 | import withBackoff from '../../../src/streamModifiers/retryStream/withBackoff' 3 | import {Subject} from 'rxjs' 4 | 5 | const sleep = time => new Promise(res => setTimeout(() => res(), time * 4)) 6 | 7 | describe('withBackoff', () => { 8 | it('The subscriber will run after a delay based on the retry number, initial wait time, max wait time and the backoffMethod', async () => { 9 | const stream = new Subject() 10 | const spy = jest.fn() 11 | 12 | withBackoff.exponential(10 * 4, 50 * 4)(stream.asObservable()).subscribe(spy) 13 | 14 | stream.next({}) // 10 sec delay 15 | await sleep(5) 16 | expect(spy.mock.calls.length).toBe(0) 17 | await sleep(11 - 5) 18 | expect(spy.mock.calls.length).toBe(1) 19 | stream.next({retryNumber: 1}) // 20 sec delay 20 | await sleep(15) 21 | expect(spy.mock.calls.length).toBe(1) 22 | await sleep(21 - 15) 23 | expect(spy.mock.calls.length).toBe(2) 24 | stream.next({retryNumber: 3}) // 50 sec delay 25 | await sleep(45) 26 | expect(spy.mock.calls.length).toBe(2) 27 | await sleep(51 - 45) 28 | expect(spy.mock.calls.length).toBe(3) 29 | }) 30 | }) -------------------------------------------------------------------------------- /tests/subjectModifiers/runWhenOnline.spec.ts: -------------------------------------------------------------------------------- 1 | import 'babel-polyfill'; 2 | import uuid from 'uuid' 3 | import runWhenOnline from '../../src/streamModifiers/runWhenOnline' 4 | import {Subject} from 'rxjs' 5 | 6 | function NetInfo() { 7 | const listeners = [] 8 | 9 | // public 10 | function addEventListener(type, handler) { 11 | if (type != 'connectionChange') throw "This mock supports only 'connectionChange' events" 12 | 13 | listeners.push(handler) 14 | } 15 | 16 | // public 17 | function addEvent(value) { 18 | listeners.forEach(h => h(!!value)) 19 | } 20 | 21 | // public 22 | function fetch() { 23 | return Promise.resolve(true) 24 | } 25 | 26 | return { 27 | isConnected: { 28 | addEventListener, 29 | addEvent, 30 | fetch 31 | } 32 | } 33 | } 34 | 35 | const sleep = time => new Promise(res => setTimeout(() => res(), time * 4)) 36 | const FunctionId = f => ({ 37 | id: uuid.v4(), 38 | handleFunction: f 39 | }) 40 | describe('Jobs run only when online', () => { 41 | it('When online runs, when offline doesnt', async () => { 42 | const stream = new Subject() 43 | const spy = jest.fn() 44 | const netInfo = NetInfo() 45 | runWhenOnline(netInfo)(stream.asObservable()).subscribe(job => job.handleFunction()) 46 | 47 | stream.next( 48 | FunctionId(() => spy('first')) 49 | ) 50 | await sleep(1) 51 | 52 | expect(spy.mock.calls.length).toBe(1) 53 | expect(spy.mock.calls[0][0]).toBe('first') 54 | 55 | netInfo.isConnected.addEvent(false) 56 | 57 | stream.next( 58 | FunctionId(() => spy('second')) 59 | ) 60 | await sleep(1) 61 | 62 | expect(spy.mock.calls.length).toBe(1) 63 | expect(spy.mock.calls[0][0]).toBe('first') 64 | 65 | netInfo.isConnected.addEvent(true) 66 | await sleep(1) 67 | 68 | expect(spy.mock.calls.length).toBe(2) 69 | expect(spy.mock.calls[1][0]).toBe('second') 70 | }) 71 | }) -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "./lib/", 4 | "rootDir": "./src/", 5 | "declaration": true, 6 | "sourceMap": true, 7 | "noImplicitAny": false, 8 | "module": "commonjs", 9 | "target": "es6", 10 | "moduleResolution": "node", 11 | "allowSyntheticDefaultImports": true, 12 | "allowJs": true, 13 | "importHelpers": true, 14 | "strict": true, 15 | "forceConsistentCasingInFileNames": true, 16 | "noImplicitReturns": true, 17 | "noUnusedLocals": true, 18 | "noUnusedParameters": true, 19 | "suppressImplicitAnyIndexErrors": true 20 | }, 21 | "include": [ 22 | "src/**/*", 23 | "tests/**/*", 24 | "types/*.d.ts", 25 | "node_modules/@types" 26 | ] 27 | } --------------------------------------------------------------------------------