-
Notifications
You must be signed in to change notification settings - Fork 467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expo next storage support config plugins #750
Comments
If it's just a matter of adding the following to
Or do you also need to update |
Hello thank you for the reply, for my needs if the next storage doesn't have this limitation : #640 (comment)
I would need that one, otherwise just having |
hmmm... if I understand you correctly, you need to be able to retrieve more than 2MB of data when reading a single key? It sounds like this "Android OS limitation" is not something that you could increase. Only the total database size. If you don't mind, what kind of data is this? Also, have you considered using something else to store the data? e.g. https://github.com/mrousavy/react-native-mmkv/ |
Hello Micheal, the exact use case of mine is with using redux-persistence it just stores all the data under one single key, I'm caching a few jsons coming back from the server, these jsons could grow over the time and that could cause the 2mb overflow problem. I had considered the expo file system, haven't tried it yet though, never had heard of mmkv! Sounds amazing I'll open an issue there to ask see if they're also using the database or not! Thank you again! |
I got a response back from mmkv sounds like it's not useful for big objects as well, but that's okay, so forgetting about the 2mb limit. How about a Plugin for changing the 6mb limit? That sounds like a good idea yet I couldn't make it myself since expo has support only for vscode for developing and validating plugins, but I have Intellij Idea, I couldn't figure out how to use the mod I know a mod exists exactly for changing gradle properties tried to use it but it's not really obvious what to do there! The hook is : withGradleProperties |
This issue has been marked as stale due to inactivity. Please respond or otherwise resolve the issue within 7 days or it will be closed. |
You don't need VS Code. I don't use it. I've written a few simple plugins and I just test them by running
Maybe these will help: |
Here is a Stackoverflow issue that basically creates a config plugin for increasing the size I also just wrote one with setting up Next Storage: // withNextStorage.ts
// Next Storage Implementation for react-native-async-storage https://react-native-async-storage.github.io/async-storage/docs/advanced/next/
import {
ConfigPlugin,
createRunOncePlugin,
withGradleProperties,
withProjectBuildGradle,
} from "@expo/config-plugins";
import { MergeResults, mergeContents } from "@expo/config-plugins/build/utils/generateCode";
const pkg = require("@react-native-async-storage/async-storage/package.json");
const addKotlinGradlePlugin = (src: string): MergeResults => {
return mergeContents({
tag: "react-native-async-storage withNextStorage config plugin",
src,
newSrc: `classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"`,
anchor: /dependencies(?:\s+)?\{/,
offset: 1,
comment: "//",
});
};
const withDangerousMod: ConfigPlugin = (config) => {
return withProjectBuildGradle(config, (config) => {
if (config.modResults.language === "groovy") {
config.modResults.contents = addKotlinGradlePlugin(config.modResults.contents).contents;
} else {
throw new Error(
"Cannot add Snapkit maven gradle because the project build.gradle is not groovy"
);
}
return config;
});
};
const withGradlePropertyMod: ConfigPlugin = (config) => {
return withGradleProperties(config, (config) => {
config.modResults.push({
type: "property",
key: "AsyncStorage_useNextStorage",
value: "true",
});
return config;
});
};
const withNextStorage: ConfigPlugin = (config) => {
return withGradlePropertyMod(withDangerousMod(config));
};
export default createRunOncePlugin(withNextStorage, pkg.name, pkg.version); I can publish this as a config plugin package. Let me know @tido64 |
I see. I wonder if we should allow users to configure AsyncStorage from a more central place, like |
I'm not sure that's right. The Expo docs say:
The above seems pretty clear on its own, but then they go on to say the stuff about using autolinking:
They also say:
So it's a bit ambiguous, but it still seems that it should be fine to modify AsyncStorage's Here's an existing config plugin that makes use of |
@wodin The config plugin I wrote above works great so I am aware of using In any case, what I was answering was that @tido64 wants this to part of the AsyncStorage package. However, that is only possible by modifying the package and its Autolinking process. The config plugin I wrote would have nothing to do with that. |
@ansh I don't really know much about Autolinking at all, despite having read the documentation on it. I also haven't looked too closely at what your config plugin actually changes in But, would it be possible to get this to work by modifying AsyncStorage's Or would the app's own |
After some digging, I just realized that we already provide an "easy" way for people to enable next storage: https://github.com/react-native-async-storage/async-storage/blob/774fb7828219823195ee704099bbbd902ffc5d07/website/docs/advanced/Next.md#enable Is this not compatible with Expo? |
hey, Happy new year everyone! From what I understand, the only way to add a custom property to If so, then the plugin would be as easy as calling |
@krizzu Happy New Year to you too :) Yes, I think you're right! |
@krizzu @wodin @tido64 I tried just adding the I forget the error but I can create a new repro if required. |
If I create a new Expo app and then run
but not in the app's So should this be in async-storage/android/build.gradle Lines 51 to 53 in cfa67c6
If it's needed for "next storage" support then maybe this if statement could be amended to something like this? if ((projectExampleDir == rootProjectDir) || useNextStorage) {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$asyncStorageKtVersion"
} |
@wodin That is a nice solution! Then the config plugin could be super simple and wouldn’t need any dangerous mods. |
Yes, that would work - original idea was that the root app (React Native app, using AsyncStorage) should apply the plugin and we'll just reuse it. With that change, simply setting |
FWIW I've been told the following:
EDIT: Corrected link: https://github.com/coil-kt/coil/blob/a3f7e9d8ce98783cf4ce1b1d84657104d6b123b7/buildSrc/build.gradle.kts#L12 |
Was there ever any progress on this? I can't find any mention of a config plugin in the documentation. Our use case is that we need to store several strings, the total size of which will exceed 6MB, while each string will be between 1 and 2MB. We are running on an expo custom dev client in the managed workflow, so while we can use config plugins, we don't have the capability to modify |
I am looking for plugin to exceed 6MB limit in expo managed app. Can someone post the solution pls. |
on expo51 i got limited in expoGO but on production im not limited, with eas build in my app.json android storage is defined like this : |
…Storage Fixes react-native-async-storage#750 Co-Authored-By: Bill Spooner <b@twodoors.dev>
Fixes react-native-async-storage#750 Co-Authored-By: Bill Spooner <b@twodoors.dev>
Fixes react-native-async-storage#750 Co-Authored-By: Bill Spooner <b@twodoors.dev>
…ge on Android Fixes react-native-async-storage#750 Co-Authored-By: Bill Spooner <b@twodoors.dev>
…ge on Android Fixes react-native-async-storage#750 Co-Authored-By: Bill Spooner <b@twodoors.dev>
…ge on Android Fixes react-native-async-storage#750 Co-Authored-By: Bill Spooner <b@twodoors.dev>
…ge on Android Fixes react-native-async-storage#750 Co-Authored-By: Bill Spooner <b@twodoors.dev>
…ge on Android Fixes react-native-async-storage#750 Co-Authored-By: Bill Spooner <b@twodoors.dev>
…ge on Android Fixes react-native-async-storage#750 Co-Authored-By: Bill Spooner <b@twodoors.dev>
…ge on Android Fixes react-native-async-storage#750 Co-Authored-By: Bill Spooner <b@twodoors.dev>
…ge on Android Fixes react-native-async-storage#750 Co-Authored-By: Bill Spooner <b@twodoors.dev>
Proposal
Hello, this 6mb limit always has been a pain in the arm, so with the new EAS build system it's now possible to lift it. (According to Brent Vatne himself the creator of expo : https://expo.canny.io/feature-requests/p/ability-to-increase-async-storage-size).
It would be great to have a config plugin : https://docs.expo.dev/guides/config-plugins/
which can add support of next storage, so that 6mb limit would get lifted.
Alternatives
The alternative of course can be not using the next storage, and the old one but be able to configure the size, that is possible if you search this text in the link I provided in the next section
Some plugins can be customized by passing an array, where the second argument is the options:
Implementation Details
I don't know much but I have seen other libraries do the same for example rn-firebase has done it, and many more.
But the full tutorial on that seems to be here : https://docs.expo.dev/guides/config-plugins/
Additional Context
No response
The text was updated successfully, but these errors were encountered: