amplify-swift
amplify-swift copied to clipboard
Using DataStore with Sync Disabled
I would like to use the DataStore and API plugins in my application. Every time I configure the DataStore and API plugins, the sync functionality of DataStore is automatically enabled. Is there a way to configure DataStore without the sync engine and configure the API plugin?
Hi, @pstance . Thanks for reaching out, I have two questions:
- Do you mean you want
DataStore
andAPI
work separately in one project (Probably you don't want the automation part between local and remote and want to do that manually)? - The two plugins are sharing one schema or have two different schemas?
please give me more details, thanks
- Yes, I want them to work separately on the same project.
- They are sharing the same schema.
Hi, @pstance .
So we don't support the separate use of DataStore
and API
especially when sharing one schema in one project because of data consistency problem.
Do you mind tell us why you want them to work separately? We would also treat this as feature request
Is it possible with two schemas?
@pstance Can you describe the use case you're trying to accomplish? There may be a different way of getting to what you want.
I would like to do this as a workaround to this issue https://github.com/aws-amplify/amplify-js/issues/6034
Hey @david-gettins, turning on/off the cloud sync depending on the network type is indeed an interesting feature. Both that and allowing you to use API and DataStore separately are being considered but at the moment neither are supported.
I believe that implementing your own integration between API and DataStore depending on the network conditions could be quite complex.
I'll keep this issue open so we track it in our backlog and will update you when make progress on it. Thanks for getting in touch with us.
Also interested in this! Slightly different application (we want to give users the ability to "opt in" on cloud sync, but everything stays local until then). This would be in addition to wifi/cellular.
If this is addressed elsewhere I've failed to find it 🙈 and would appreciate any direction.
Is it not possible to use DataStore.stop()/DataStore.start() to control the cloud synchronization? Similar like in this example in the docs: https://docs.amplify.aws/lib/datastore/sync/q/platform/js#reevaluate-expressions-at-runtime
EDIT: Just saw this comment in the docs:
Start
Synchronization starts automatically whenever you run any DataStore operation (query(), save(), delete(), observe().) You can also explicitly begin the process with DataStore.start():
Apparently, sync will be enabled automatically after ever operation. Not sure if a workaround would be to call DataStore.stop() after every operation to prevent sync to the cloud?
Apparently, sync will be enabled automatically after ever operation. Not sure if a workaround would be to call DataStore.stop() after every operation to prevent sync to the cloud?
It would not be a reliable workaround, since the async processes would kick off and at least partially complete before the stop
was invoked.
My problem: Want to use Datastore locally only. No sync. Just a nice little datastore abstracting away the woes of local storage for various platforms.
My (very dirty) solution: I removed Amplify.configure(awsexports) line from my index.tsx. Now I get an explicit warning telling me that my data isn't syncing to the cloud. But that's okay!
Also in the docs, there is this bit which I'm curious how one can go achieve it after completing the Amplify's official tutorial
My problem: Want to use Datastore locally only. No sync. Just a nice little datastore abstracting away the woes of local storage for various platforms.
My (very dirty) solution: I removed Amplify.configure(awsexports) line from my index.tsx. Now I get an explicit warning telling me that my data isn't syncing to the cloud. But that's okay!
Also in the docs, there is this bit which I'm curious how one can go achieve it after completing the Amplify's official tutorial
Thanks for sharing this, I am currently using this as my work around until I figure out a better solution. I synced my app with the cloud for testing purposes to make sure everything worked as intended but now want to continue development work which includes adding/updating schemas. I cannot find an easy way to just turn it off.
Additionally I'm trying to find a way to conditionally sync users' data to the cloud dependent on whether or not they have a paid subscription. Meaning free users would only be able to store their data locally unless they chose to upgrade to a paid service.
Any help on this would be much appreciated!
My problem: Want to use Datastore locally only. No sync. Just a nice little datastore abstracting away the woes of local storage for various platforms. My (very dirty) solution: I removed Amplify.configure(awsexports) line from my index.tsx. Now I get an explicit warning telling me that my data isn't syncing to the cloud. But that's okay! Also in the docs, there is this bit which I'm curious how one can go achieve it after completing the Amplify's official tutorial
Thanks for sharing this, I am currently using this as my work around until I figure out a better solution. I synced my app with the cloud for testing purposes to make sure everything worked as intended but now want to continue development work which includes adding/updating schemas. I cannot find an easy way to just turn it off.
Additionally I'm trying to find a way to conditionally sync users' data to the cloud dependent on whether or not they have a paid subscription. Meaning free users would only be able to store their data locally unless they chose to upgrade to a paid service.
Any help on this would be much appreciated!
@jro55 Have you figured it out?
Related Issue https://github.com/aws-amplify/amplify-swift/issues/848