Skip to content

Commit 945deba

Browse files
committed
update local maven for android
1 parent 2d6f81b commit 945deba

File tree

5 files changed

+64
-29
lines changed

5 files changed

+64
-29
lines changed

docs/api/usage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ The data in one storage instance is scoped to its name: using different names en
3232

3333
!!! warning "Windows platform"
3434

35-
As of AsyncStorage v3.0, Windows platform does not support scoped storages. It fallsback to previous implementation - single storage per application.
35+
As of AsyncStorage v3.0, Windows platform does not support scoped storages. It falls back to previous implementation - single storage per application.
3636

3737
## Using a storage
3838

docs/index.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,26 @@ npm install @react-native-async-storage/async-storage
2929
yarn add @react-native-async-storage/async-storage
3030
```
3131

32-
On iOS/macOS, don’t forget to install pods:
32+
### Android
33+
34+
Inside your `android/build.gradle(.kts)` file, add link to local maven repo:
35+
36+
```groovy
37+
allprojects {
38+
repositories {
39+
// ... others like google(), mavenCenterl()
40+
41+
maven {
42+
// or uri("path/to/node_modules/@react-native-async-storage/async-storage/android/local_repo")
43+
url = uri(project(":react-native-async-storage_async-storage").file("local_repo"))
44+
}
45+
}
46+
}
47+
```
48+
49+
### iOS/macOS
50+
51+
Install cocoapods dependencies:
3352

3453
```shell
3554
# inside macos/ios directory

docs/migration-to-3.md

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,52 @@
22

33
AsyncStorage v3 introduces some breaking changes to simplify the API and make it more consistent.
44

5-
## AsyncStorage instance needs to be created now
5+
## Key changes:
66

7-
AsyncStorage v3 introduced scoped storages, which needs to be created before use. Head to [Usage page](api/usage.md#creating-a-storage) to learn more.
7+
### Installation changes
88

9-
## Default export points to v2 storage
9+
Android requires local maven repo to be added in your `build.gradle(.kts)` file. Head over to [Installation step for Android](index.md#android) to learn more.
1010

11-
To make transition easier, the default export still points to the v2 storage implementation, ensuring that no existing data is lost.
1211

13-
## Removed callback arguments
12+
### `AsyncStorage` is now instance-based
1413

15-
All methods now return Promises, and callbacks have been removed from all methods.
14+
In v3, AsyncStorage is no longer a singleton.
15+
Each instance represents an **isolated storage area**, providing separation between data sets. Head over to [Usage page](api/usage.md#creating-a-storage) to learn more.
1616

17-
## Removed merge functionality
17+
```typescript
18+
// create seperate storages
19+
const userStorage = createAsyncStorage('user');
20+
const cacheStorage = createAsyncStorage('cache');
21+
```
22+
23+
### Default export still points to v2 storage
24+
25+
To make upgrading smoother, the default export continues to reference the v2 implementation.
26+
This ensures that:
27+
28+
- Your app continues to access previously stored data.
29+
- You can migrate incrementally to v3 instances.
30+
31+
```typescript
32+
// Still works (uses v2 backend)
33+
import AsyncStorage from '@react-native-async-storage/async-storage';
34+
await AsyncStorage.setItem('foo', 'bar');
35+
```
36+
37+
### Callbacks removed — Promises only
38+
39+
All methods are now Promise-based.
40+
The old callback arguments have been removed to make the API simpler and more consistent.
41+
42+
### Removed merge functionality
1843

1944
AsyncStorage's "merge" behavior has historically been inconsistent across platforms. Rather than enforcing a platform-specific merging strategy, the merge API has been removed to avoid ambiguity.
2045

21-
## Method signature changes
46+
### Errors are more predictable now
47+
48+
All errors now thrown from `AsyncStorage` are instances of `AsyncStorageError` containing `type` of the error it represents. Head over to [Errors page](api/errors.md) to learn more.
49+
50+
### Method signature changes
2251

2352
The core methods
2453

@@ -30,7 +59,7 @@ The core methods
3059

3160
retain their signatures from v2, ensuring backward compatibility.
3261

33-
### multiGet
62+
#### multiGet
3463

3564
Renamed to `getMany` and returns a `Record<string, string | null>`, following a "what you request is what you get" rule: every key you pass in the request appears in the returned object, with `null` for keys that don’t exist in storage.
3665

@@ -43,7 +72,7 @@ Renamed to `getMany` and returns a `Record<string, string | null>`, following a
4372
+ getMany(keys: string[]): Promise<Record<string, string | null>>;
4473
```
4574

46-
### multiSet
75+
#### multiSet
4776

4877
Renamed to `setMany`, accepts a `Record<string, string>` of key-value entries.
4978

@@ -56,7 +85,7 @@ Renamed to `setMany`, accepts a `Record<string, string>` of key-value entries.
5685
+ setMany(entries: Record<string, string>): Promise<void>;
5786
```
5887

59-
### multiRemove
88+
#### multiRemove
6089

6190
Renamed to `removeMany`, accepts list of keys.
6291

@@ -69,6 +98,3 @@ Renamed to `removeMany`, accepts list of keys.
6998
+ removeMany(keys: string[]): Promise<void>;
7099
```
71100

72-
## Errors are more predictable now
73-
74-
All errors now thrown from `AsyncStorage` are instances of `AsyncStorageError` containing `type` of the error it represents. Head over to [Errors page](api/errors.md) to learn more.

examples/react-native/android/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,8 @@ allprojects {
3939
}()
4040
mavenCentral()
4141
google()
42+
maven {
43+
url = uri(project(":react-native-async-storage_async-storage").file("local_repo"))
44+
}
4245
}
4346
}

packages/async-storage/android/build.gradle

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,6 @@ android {
8484
}
8585
}
8686

87-
project.afterEvaluate {
88-
rootProject.allprojects {
89-
println "projectname: ${it.name}"
90-
repositories {
91-
def proj = project(":react-native-async-storage_async-storage")
92-
maven {
93-
url = uri("${proj.projectDir}/local_repo")
94-
}
95-
}
96-
}
97-
}
98-
9987
repositories {
10088
mavenCentral()
10189
google()
@@ -107,7 +95,6 @@ dependencies {
10795

10896

10997
def room_version = getExtOrDefault("ROOM_VERSION")
110-
11198
implementation "androidx.room:room-runtime:$room_version"
11299
implementation "androidx.room:room-ktx:$room_version"
113100
ksp "androidx.room:room-compiler:$room_version"

0 commit comments

Comments
 (0)