GithubHelp home page GithubHelp logo

Comments (4)

nilbus avatar nilbus commented on July 20, 2024

Check out Store.clean and the places where clean is called, in localsync update and delete. Once you figure out the scenario that creates this error condition, we can create a failing spec that reproduces it and fix the issue.

from backbone.dualstorage.

Cinezaster avatar Cinezaster commented on July 20, 2024

If I run syncDirtyAndDestroyed(); should I pass through localsync function? Because it doesn't.

from backbone.dualstorage.

nilbus avatar nilbus commented on July 20, 2024
Backbone.Collection.prototype.syncDirty = (options) ->
  store = localStorage.getItem("#{getStoreName(@)}_dirty")
  ids = (store and store.split(',')) or []

  for id in ids
    @get(id)?.save(null, options)

For each id marked dirty, it tries to get the model from the collection by that id. If a model with that id exists, it will try to save it. Save should call sync, which is overridden to be dualsync.

dualsync = (method, model, options) ->
  # ...

  # execute only online sync
  return onlineSync(method, model, options) if _.result(model, 'remote') or _.result(model.collection, 'remote')

  # execute dual sync
  # ...

If neither the model nor collection have a truthy remote property, then it will continue to try to dualsync. Double-check this.

As dualsync executes, localsync generally always gets called below backbone.dualstorage.coffee:283. Trace the execution to see what's actually happening.

from backbone.dualstorage.

Cinezaster avatar Cinezaster commented on July 20, 2024

Got it. The response on the PUT call is empty, but status is 200. Backbone handles this as an error but since the error is never logged I didn't know the call was not successful. I fixed this by adding

  Backbone.ajax = function() {
    var args = Array.prototype.slice.call(arguments, 0);
    if (args[0].type === 'PUT') {
        args[0].dataType = "text";
    }
    return Backbone.$.ajax.apply(Backbone.$, args);
};```


This is not a bug in this library. A bit of error feedback would be nice.

from backbone.dualstorage.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.