t73liu / redux-persist-expo-filesystem Goto Github PK
View Code? Open in Web Editor NEWredux-persist storage engine using Expo's filesystem API
Home Page: https://www.npmjs.com/package/redux-persist-expo-filesystem
License: MIT License
redux-persist storage engine using Expo's filesystem API
Home Page: https://www.npmjs.com/package/redux-persist-expo-filesystem
License: MIT License
The method or property expo-file-system.getInfoAsync is not available on web, are you sure you've linked all the native dependencies properly?
Is this working with expo web app build?
I wasn't able to get this work with v6 and redux-persist. Not sure of there is a bug in redux-persist or if this component needs an update to work with v6
"redux-persist failed to create sync storage, failing back to noop storage" when I try to pass this component here as storage.
Works perfectly fine with v5
The store is empty after every restart app on android in the standalone build. In dev mode, all work fine
Hi, would be nice if this included a license so that credit could be properly given.
setItem callback in the redux persist is expected to return a promise that resolves upon successful writing. However, the code below only waits for getInforAsync to resolve and does not handle the resolution of the setItem promise after a successful write operation.
setItem(key, value) {
const folderPath = generateFolderPath();
return FileSystem.getInfoAsync(folderPath)
.then(info => {
const filePath = generateFilePath(key);
if (info.exists) {
writeFile(filePath, value);
} else {
FileSystem.makeDirectoryAsync(folderPath, {intermediates: true})
.then(() => writeFile(filePath, value));
}
});
}
function writeFile(path, value) {
FileSystem.writeAsStringAsync(path, value);
}
setItem(key, value) {
const folderPath = generateFolderPath();
return FileSystem.getInfoAsync(folderPath)
.then(async info => {
const filePath = generateFilePath(key);
if (info.exists) {
await writeFile(filePath, value);
} else {
await FileSystem.makeDirectoryAsync(folderPath, {intermediates: true})
.then(() => writeFile(filePath, value));
}
});
}
async function writeFile(path, value) {
await FileSystem.writeAsStringAsync(path, value);
}
Expected Behavior: The system should wait for the resolution of both promises, and the execution of console.log("after execution")
should occur at the end.
// Create a function that returns a Promise
function examplePromise(value) {
return new Promise((resolve, reject) => {
// Simulate a delay of 20 seconds using setTimeout
setTimeout(() => {
// Check the value and resolve or reject the Promise accordingly after the delay
if (value) {
// If the value exists, resolve the Promise
console.log('execution: examplePromise: ' + value)
resolve('Promise resolved successfully with: ' + value);
} else {
// If the value doesn't exist, reject the Promise
reject('Promise rejected: No value provided');
}
}, 20000); // 20 seconds delay (20000 milliseconds)
});
}
const setItem = ()=>{
return examplePromise(1).then((res)=>{
examplePromise(2)
});
}
const parent =async()=>{
console.log("before execution")
await setItem()
console.log("after execution")
}
parent()
before execution
execution: examplePromise: 1
after execution
execution: examplePromise: 2
// Create a function that returns a Promise
function examplePromise(value) {
return new Promise((resolve, reject) => {
// Simulate a delay of 20 seconds using setTimeout
setTimeout(() => {
// Check the value and resolve or reject the Promise accordingly after the delay
if (value) {
// If the value exists, resolve the Promise
console.log('execution: examplePromise: ' + value)
resolve('Promise resolved successfully with: ' + value);
} else {
// If the value doesn't exist, reject the Promise
reject('Promise rejected: No value provided');
}
}, 20000); // 20 seconds delay (20000 milliseconds)
});
}
const setItem = ()=>{
return examplePromise(1).then(async(res)=>{
await examplePromise(2)
});
}
const parent =async()=>{
console.log("before execution")
await setItem()
console.log("after execution")
}
parent()
before execution
execution: examplePromise: 1
execution: examplePromise: 2
after execution
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.