Closed ptdede closed 5 years ago
And when i build release for iOS, my app will stuck (not responding). Is this related with the warning?
It is. The warning explains why the app appears stuck. Take a look at the docs: https://github.com/Nozbe/WatermelonDB/blob/master/docs/Actions.md
Also, I have a question about multithreading. Is it multithreaded in React Native? Thanks!
Yes. Native database code runs in a separate thread from JS thread and main thread.
Yes. Native database code runs in a separate thread from JS thread and main thread.
Very cool!
It is. The warning explains why the app appears stuck. Take a look at the docs: https://github.com/Nozbe/WatermelonDB/blob/master/docs/Actions.md
Yes, i saw the docs. So, i have to use action in model instead using it from exported watermelon database?
Yes, i saw the docs. So, i have to use action in model instead using it from exported watermelon database?
you can do database.action
. The problem is that you have competing actions. You have some action running that has not completed (or errored out). You should see in console the body of the function that's running.
Either that or you're trying to run database.action from inside another action. In which case you need to use subAction API
Let me know if this makes sense to you.
You should see in console the body of the function that's running.
Yep, so the function that causing this error is database.action
.
I test it by transform the function into:
export async function asyncSaveOfflineDb (...) {
await database.action(async action => {})
}
I am pretty sure that i'm not running database.action
inside other action.
But, I run asyncSaveOfflineDb
multiple time simultaneously. For example I have <DataFetcher thatFetch={url} />
, and i render multiple <DataFetcher />
in a Class (one screen). That component also have functionality to save data into localDB (asyncSaveOfflineDb
).
Is this the culprit? So, i can't use watermelon database
object by that way(simultaneously)?
Update:
I found that omitting actionsEnabled: true
is solving this problem 😕
export const database = new Database({
adapter,
modelClasses: registeredModel,
actionsEnabled: true // --> omit this
})
its hard to see how not enabling actions (assuming that actionsEnabled does indeed do what it says it does!) would fix a problem with performing an action. Its also apparently mandatory to set actionsEnabled when initialising the database connection, so I'm now struggling to resolve the same error as the OP
Hi! I Just discover this project and it's amazing! 🥇
I have several question about implementation to my project. So, I have function like this:
After several time trying, i got this warning message:
And when i build release for iOS, my app will stuck (not responding). Is this related with the warning?
Here is the first line error trace:
Also, I have a question about multithreading. Is it multithreaded in React Native? Thanks!