Giter VIP home page Giter VIP logo

Comments (2)

nilbus avatar nilbus commented on September 27, 2024

Mentioned the wrong issue in the commit that closed this. Whoops!

from backbone.dualstorage.

nilbus avatar nilbus commented on September 27, 2024

store.clean is the call you're looking for. It wasn't obvious, because it can clean both dirty and destroyed records and doesn't contain either string.

Here's what generally happens (I'll go through syncDestoryed, but the same applies to syncDirty:

  1. syncDestroyed calls model.destroy()

  2. Destroying the model leads to dualsync's when 'delete'

  3. For models that have been successfully saved, localsync('delete', model, options)

    options.success = (resp, _status, _xhr) ->
      return useOfflineStorage() if hasOfflineStatusCode options.xhr
      localsync(method, model, options)
  4. localsync when 'delete' calls store.destroy(model) and then store.clean to clean either 1) 'dirty' because it had never been created online and was marked dirty for creation, or 2) 'destroyed' because it was created online and deleted offline. See this annotated source:

    when 'delete'
      store.destroy(model)
      # options.dirty implies that this delete is using offline storage
      if options.dirty && !model.hasTempId()
        store.destroyed(model)
      else # !options.dirty || model.hasTempId()
        if model.hasTempId()
          store.clean(model, 'dirty')
        else # !options.dirty
          store.clean(model, 'destroyed')

The two places I can see this might be going wrong:

  1. In step 3, return useOfflineStorage() if hasOfflineStatusCode options.xhr. I suspect that hasOfflineStatusCode(options.xhr) is returning for you, because it seems hasOfflineStatusCode was also triggering #145 for you. Let me know if you can confirm this in debugging. If hasOfflineStatusCode is returning true, then leaving the records marked dirty/destroyed is the intended behavior.
  2. There could be some edge case that I'm not thinking of for the logic in step 4 that causes something not to be cleaned that should.

comments in the code would help

noted. I also would like to improve the ease of understanding.

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.