Skip to content

Commit 6d0aa95

Browse files
authored
docs: make resource fetcher documentation coherent with current code (#1001)
This PR updates the docs to match current state of resource fetcher. ## Description <!-- Provide a concise and descriptive summary of the changes implemented in this PR. --> ### Introduces a breaking change? - [ ] Yes - [x] No ### Type of change - [ ] Bug fix (change which fixes an issue) - [ ] New feature (change which adds functionality) - [x] Documentation update (improves or adds clarity to existing documentation) - [ ] Other (chores, tests, code style improvements etc.) ### Tested on - [ ] iOS - [ ] Android ### Testing instructions <!-- Provide step-by-step instructions on how to test your changes. Include setup details if necessary. --> ### Screenshots <!-- Add screenshots here, if applicable --> ### Related issues <!-- Link related issues here using #issue-number --> ### Checklist - [ ] I have performed a self-review of my code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have updated the documentation accordingly - [ ] My changes generate no new warnings ### Additional notes <!-- Include any additional information, assumptions, or context that reviewers might need to understand this PR. -->
1 parent e3f886d commit 6d0aa95

8 files changed

Lines changed: 334 additions & 221 deletions

File tree

.cspell-wordlist.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,4 @@ nˈɛvəɹ
180180
ˈɛniwˌʌn
181181
ˈɛls
182182
Synchronizable
183+
stringifying

docs/docs/01-fundamentals/01-getting-started.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,32 +38,59 @@ For supported React Native and Expo versions, see the [Compatibility table](../0
3838

3939
## Installation
4040

41-
Installation is pretty straightforward, just use your favorite package manager.
41+
Installation is pretty straightforward, use your package manager of choice to install the package and some peer dependencies required to streamline model downloads. If you want to implement your custom model fetching logic, see [this document](../08-resource-fetcher/02-custom-adapter.md).
4242

4343
<Tabs>
4444
<TabItem value="npm" label="NPM">
4545

4646
```
4747
npm install react-native-executorch
48+
# For Expo projects
49+
npm install react-native-executorch-expo-resource-fetcher
50+
# For bare React Native projects
51+
npm install react-native-executorch-bare-resource-fetcher
4852
```
4953

5054
</TabItem>
5155
<TabItem value="pnpm" label="PNPM">
5256

5357
```
5458
pnpm install react-native-executorch
59+
# For Expo projects
60+
pnpm install react-native-executorch-expo-resource-fetcher
61+
# For bare React Native projects
62+
pnpm install react-native-executorch-bare-resource-fetcher
63+
5564
```
5665

5766
</TabItem>
5867
<TabItem value="yarn" label="YARN">
5968

6069
```
6170
yarn add react-native-executorch
71+
# For Expo projects
72+
yarn install react-native-executorch-expo-resource-fetcher
73+
# For bare React Native projects
74+
yarn install react-native-executorch-bare-resource-fetcher
6275
```
6376

6477
</TabItem>
6578
</Tabs>
6679

80+
:::warning
81+
Before using any other API, you must call `initExecutorch` with a resource fetcher adapter at the entry point of your app:
82+
83+
```js
84+
import { initExecutorch } from 'react-native-executorch';
85+
import { ExpoResourceFetcher } from 'react-native-executorch-expo-resource-fetcher';
86+
// or BareResourceFetcher for Expo projects
87+
88+
initExecutorch({ resourceFetcher: ExpoResourceFetcher });
89+
```
90+
91+
Calling any library API without initializing first will throw a `ResourceFetcherAdapterNotInitialized` error.
92+
:::
93+
6794
Our library offers support for both bare React Native and Expo projects. Please follow the instructions from [Loading models section](./02-loading-models.md) to make sure you setup your project correctly. We encourage you to use Expo project if possible. If you are planning to migrate from bare React Native to Expo project, the link (https://docs.expo.dev/bare/installing-expo-modules/) offers a guidance on setting up Expo Modules in a bare React Native environment.
6895

6996
If you plan on using your models via require() instead of fetching them from a url, you also need to add following lines to your `metro.config.js`:
@@ -89,7 +116,7 @@ Because we are using ExecuTorch under the hood, you won't be able to build iOS a
89116
Running the app with the library:
90117

91118
```bash
92-
yarn run expo:<ios | android> -d
119+
yarn <ios | android> -d
93120
```
94121

95122
## Supporting new models in React Native ExecuTorch

docs/docs/05-utilities/resource-fetcher.md

Lines changed: 0 additions & 218 deletions
This file was deleted.

0 commit comments

Comments
 (0)