This is a migrated thread and some comments may be shown as answers.

Offline storage Sync

11 Answers 260 Views
HTML5, CSS, JavaScript
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Chris
Top achievements
Rank 1
Chris asked on 05 Nov 2014, 08:28 AM
Hi,
I was after some clarification on using the Kendo datasource and the Everlive dialect in offline mode.
If the datasource is set to autoSync: true when i move the datasource back to online will the datasource automatically sync the changes with the backend services or do i need to call the sync method?

Thanks Chris

11 Answers, 1 is accepted

Sort by
0
Anton Dobrev
Telerik team
answered on 05 Nov 2014, 05:00 PM
Hi Chris,

Thank you for your question.

The data source will sync the changes from the offline state once its online() method is called. Consider the following example for simplicity - the comments in the code will outline the behavior.

dataSource.fetch(function() {
    // go in offline mode
    dataSource.online(false);
 
    // add item to the data source
    var model = dataSource.add();
    model.Id = "1";
    model.Text = "My text";
 
    // go online - the new data is posted immediately
    dataSource.online(true);
});

The above data source is not configured to use auto sync, it uses the simplest configuration. On the other hand, the autoSync configuration will try to connect to the server once there are any changes in the data source. If you'd like to have more control of the data synchronization you may consider syncing the data yourself by calling the sync() method or by toggling the online state.

Let me know if this is helpful for you and if you have further questions.

Regards,
Anton Dobrev
Telerik
 

Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

 
0
David Gerding
Top achievements
Rank 1
answered on 23 Nov 2014, 05:38 PM
Hi Anton,
I, too, am really interested in the offline sync/storage in the DataSource update for KendoUI.  Has anyone done a demo app yet that can show a common implementation? I've got my own approach that syncs to Sqlite on the client - but it's pretty rough around the edges.  What are the storage limitations with the offline datasource?  Is it using localstorage?  Any clues, details or working examples in the mobile context greatly appreciated.  

Thanks,
Dave Gerding
0
Anton Dobrev
Telerik team
answered on 25 Nov 2014, 03:38 PM
Hello,

I made a simple example to showcase the feature based on our Grocery List interactive tutorial. In the initialization of the app its subscribes to the online/offline events and toggles the data source online state accordingly.

You can try the sample by importing it in your favorite AppBuilder client and switching between the network connections available in the simulator. They will simulate the Cordova Networik Connection API.

Note that the project should be connected to a Backend Services project. The data source is configured to work with a Content Type named "Groceries", but you can set your own content type name.

@Dave

I hope that this article will answer your questions.

Regards,
Anton Dobrev
Telerik
 

Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

 
0
David Gerding
Top achievements
Rank 1
answered on 26 Nov 2014, 02:18 AM
Anton, 
Great!  Thanks as always for your help.

Dave Gerding
0
Chris
Top achievements
Rank 1
answered on 28 Nov 2014, 01:32 PM
Wher is the sample app you created. I would like to take a look at this.
Chris
0
Anton Dobrev
Telerik team
answered on 01 Dec 2014, 04:04 PM
Hello,

Seems that the attached file in the thread is not visible. Here is the link to the repo in GitHub.

Also, I suggest reading the following series of blog posts in order to handle better the offline/online state of the data source and examine the Cordova Network Connection API.

Let me know if you have further questions.

Regards,
Anton Dobrev
Telerik
 

Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

 
0
Marlon
Top achievements
Rank 1
answered on 01 Dec 2014, 10:11 PM
I asked this question during the presentation but had to drop off and never heard if it was answered. If this offline funcitonality if used in a hybrid app as you demo, how will this persist if the app is killed? As far as I know, if the app is terminated (at least on iOS) the browser's localStorage would be lost as well. 

0
Anton Dobrev
Telerik team
answered on 04 Dec 2014, 01:52 PM
Hello,

@Marlon
By default, the data source uses the localStorage API for the data stored offline.

The data in the local storage is persisted between starts/stops of the app, also on iOS devices. However, the data in the local storage could not be persisted between installations. 

Please, let me know if you have questions. 

Regards,
Anton Dobrev
Telerik
 

Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

 
0
Marlon
Top achievements
Rank 1
answered on 08 Jan 2015, 04:25 PM
Anton,

My question wasn't regarding installations of the app.  I understand that localStorage is cleared if the app is removed . I'm asking about the app being closed  - not just suspended. Are you saying that the localStorage will be maintained if the app is completely closed? (on iOS this could be done if the app crashes or if the user chooses to force the app to close via the App Switcher)
0
Chris
Top achievements
Rank 1
answered on 08 Jan 2015, 04:31 PM
Hi,
I have found that if the app is completely closed on iOS then the local storage is lost.
We are looking at way of using sqlLite as a means of persisting the data between shut downs etc. It would be nice if persistence be built into the datasource.

Chris
0
Anton Dobrev
Telerik team
answered on 13 Jan 2015, 02:46 PM
Hi,

@Marlon
Based on my observations and tests the localStorage on iOS using Cordova 3.5 is persistent between app starts/stops. Also, it could be persisted between app installations if the iCloud sync is enabled on the device and a backup of the device has been done.

What I am guessing here is that Chris refers to the Kendo Data Source in offline mode that uses localStorage. The Data Source (the "vanilla" one) is configured to search in the local storage if it is set to offline, so if there is any data stored, it will be used by the data source. It appears that the data source will initially try to load a resource from the server, even if there is no internet connection available at the moment and given that the items are stored in the localStorage. Could you please specify, is this the case here?

Indeed, depending on the requirements, you can save the data using the SQLite plugin in AppBuilder.

Please, let me know if you have any questions or suggestions.

Best regards,
Anton Dobrev
Telerik
 

Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

 
Tags
HTML5, CSS, JavaScript
Asked by
Chris
Top achievements
Rank 1
Answers by
Anton Dobrev
Telerik team
David Gerding
Top achievements
Rank 1
Chris
Top achievements
Rank 1
Marlon
Top achievements
Rank 1
Share this question
or