
RfTouch sees light
WARNING
Legacy article - project is no longer active and not likely to become active
RfTouch is a framework for Sencha Touch 2. As it is right now, the project is at its very beginning. Currently, it offers a ReloadStore, which is a simple addition to the default store, so it can handle reloads. In itself, it’s nothing special, just a simplification of a common usage when using ST 2 as part of a native app.
To try it out, go to https://github.com/rohdef/rftouch and download the RfTouch folder. Put the folder in your project and add RfTouch to the loader:
Ext.Loader.setPath({
'Ext': 'touch/src',
'RfTouch': 'RfTouch', // Make sure the value of RfTouch match the path to RfTouch
'Project': 'app'
});
Then you can create your own store, almost like you’d normally create a store, except that you extend RfTouch.data.ReloadStore
.
Ext.define('Project.store.MyStore', {
extend: 'RfTouch.data.ReloadStore',
config: {
// Setting retries to 5, default is 2
// Note that a retry of 2 causes 3 tries - try, retry and retry
retries: 5,
listeners: {
bailout: 'bailoutHandle'
}
},
bailoutHandle: function(store) {
// Note retryLoad, this resets the try-count, otherwise it will only try once,
// since the amount of reloads have already been used.
Ext.Msg.alert('Load failed', 'Press ok to try again', store.retryLoad);
}
});
From here on you should just listen to the bailout event, which specifies that the store didn’t get any successful response from the proxy and use the resetReload method if you want to reset the retry count (note that to start with the retry count is 0, so load will also work on the first load, but will not if the bailout handler allows retrying).
Upcoming: RfMap – an Ext.Map that handles connectivity.