Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

localStorage should add every instance to the universal set #336

Open
imaustink opened this issue Aug 2, 2017 · 5 comments
Open

localStorage should add every instance to the universal set #336

imaustink opened this issue Aug 2, 2017 · 5 comments
Assignees

Comments

@imaustink
Copy link
Contributor

imaustink commented Aug 2, 2017

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

@nlundquist
Copy link
Contributor

you probably just need to include the data/callbacks & data/callbacks-cache behaviors

@nlundquist
Copy link
Contributor

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

@chasenlehara
Copy link
Member

@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.

@imaustink
Copy link
Contributor Author

@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.

@imaustink
Copy link
Contributor Author

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants