can-connect
can-connect copied to clipboard
localStorage should add every instance to the universal set
When trying to use can-connect
as an interface for localStorage only, no HTTP calls, .getAll({})
results in {message: "no data", error: 404}
.
This is the connection behavior I am using:
Todo.connection = connect([
require('can-connect/data/localstorage-cache/localstorage-cache'),
require('can-connect/constructor/constructor'),
require('can-connect/can/map/map')
],{
Map: Todo,
List: Todo.List,
name: 'todo',
algebra: Todo.algebra
});
This branch contains my work-in-progress where I am using this behavior: https://github.com/canjs/todomvc/tree/update-canjs-example-to-3.x
cc: @justinbmeyer
you probably just need to include the data/callbacks & data/callbacks-cache behaviors
oh and localstorage-cache should be on a separate connection that is passed to the Todo.connection as the 'cacheConnection' property, e.g: https://canjs.com/doc/can-connect/data/localstorage-cache/localstorage-cache.html#Use
@imaustink I assigned this to you to figure out if @nlundquist’s recommendations cover your needs, or if this is a bug that needs to be fixed.
@chasenlehara I had a good talk with @nlundquist about this. As it stands, can-connect
won't work with only localStorage
. Nils explained that adding this functionality would fundamentally change how caching behaves and suggested discussing this further with @justinbmeyer to confirm this is the right plan of action. Between other priorities and the retreat, I have not been able to discuss this with Justin yet. I am hoping we'll be able to talk it over this week.
@justinbmeyer the problem is that the localstorage behavior currently can’t return lists that weren’t calculated by some backend and then cached in it - to work as a data source it will need to be able to calculate lists itself. The question is how that should be implemented.