This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// How to define: | |
// -------------- | |
var callableObjectFn = function() { | |
// Use CallableObject as name in constructor function, but also when setting property below. | |
var CallableObject = (function(CallableObject) { | |
return function() { | |
return CallableObject(); | |
}; | |
}(callableObjectFn)); | |
CallableObject.property = 'value'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Initialize the Facebook SDK. | |
FB.init({ | |
appId: '<your-app-id>', | |
oauth: true | |
/* additional properties */ | |
}); | |
// Open login popup. | |
FB.login(function(response) { | |
if(response.authResponse) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Initialize the Facebook SDK. | |
FB.init({ | |
appId: '<your-app-id>', | |
oauth: true | |
/* additional properties */ | |
}); | |
// Open login popup. | |
FB.login(function(response) { | |
if(response.authResponse) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// "items" is the collection name. | |
var Item = Kinvey.Entity.extend({ | |
constructor: function(attributes) { | |
Kinvey.Entity.prototype.constructor.call(this, attributes, 'items', { | |
store: 'offline', | |
options: { policy: 'cachefirst' } | |
}); | |
} | |
}); | |
var Items = Kinvey.Collection.extend({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
<script> | |
window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB || document.write('<script src="IndexedDBShim.min.js"><\/script>'); | |
</script> | |
<script src="//da189i1jfloii.cloudfront.net/js/kinvey-js-0.9.8.min.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Kinvey.Sync.configure({ | |
conflict: Kinvey.Sync.serverAlwaysWins | |
/* or: | |
conflict: Kinvey.Sync.clientAlwaysWins | |
*/ | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var entity = new Kinvey.Entity({/*attributes*/}, 'collection', { | |
store: 'offline', | |
options: { policy: 'cachefirst' }// Optional, caching policy. | |
}); | |
var collection = new Kinvey.Collection('collection', { | |
store: 'offline', | |
options: { policy: 'cachefirst' }// Optional, caching policy. | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Kinvey.init({ | |
appKey: '<your-app-key>', | |
appSecret: '<your-app-secret>', | |
sync: true | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var collection = new Kinvey.Collection('scores', { | |
store: 'cached', | |
options: { policy: 'cachefirst' } | |
}); | |
// The leaderboard should override the collections cachefirst policy. | |
var leaderboard = new Kinvey.Aggregation().on('player'); | |
collection.aggregate(leaderboard, { | |
policy: 'nocache',// Overrides cachefirst policy. | |
success: function(response) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var entity = new Kinvey.Entity({/*attributes*/}, 'collection', { | |
store: 'cached', | |
options: { policy: 'cachefirst' } | |
}); | |
entity.load('my-entity', { | |
success: function(response) { | |
// response is the entity instance. | |
} | |
}); |