Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var coolSocket = conenct.behavior("cool-socket", function(base){
return {
init: function(){
this.socket = something();
this.socket.wasOffAndNowIsOn(function(){
// get last date from localStorage
var lastDate = READ_FROM_LOCALSTORAGE;
this.socket.get(extend({},set, {since: lastDate})).then(function(newData){
newData.data.forEach(this.createInstance)
})
})
},
getListData: function(set){
//
return this.cacheConnection.getListData(set).then(function(cachedData){
var lastDate = READ_FROM_LOCALSTORAGE;
this.socket.ready.then(()=>{
this.socket.get(extend({},set, {since: lastDate})).then(function(newData){
return {data: cacheData.data.concat(newData.data)}
})
})
})
}
}
});
connect([
require("can-connect/constructor/"),
require("can-connect/constructor/store/"),
... // all other behaviors here
coolSocket
],{
algebra: ...,
Map: Todo,
...
})
Todo.getList({});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.