@titanium/turbo
Version:
<p align="center"> <img src="https://cdn.secure-api.org/images/turbo-title_400.png" /><br> <a href="https://www.npmjs.com/package/@titanium/turbo"> <img src="https://img.shields.io/npm/v/@titanium/turbo.png" /> </a> </p>
30 lines (25 loc) • 595 B
JavaScript
var ID = 'instance';
var app = Alloy.createModel('modelTab');
// Change label when 'count' changes on model
app.on('fetch change:count', function(model) {
$.label.text = 'model: ' + JSON.stringify(app.attributes);
});
// fetch model from Ti.App.Properties adapter
app.set('id', ID);
app.fetch();
////////////////////////////////////
////////// event handlers //////////
////////////////////////////////////
function create(e) {
app.save(app.defaults);
}
function destroy(e) {
app.destroy();
}
function increment(e) {
app.set({
count: app.get('count') + 1,
id: ID
});
app.save();
}