GithubHelp home page GithubHelp logo

Comments (9)

nilbus avatar nilbus commented on August 20, 2024

Thanks @evantishuk, I'll take a look.

from backbone.dualstorage.

nilbus avatar nilbus commented on August 20, 2024

Yes, there are definitely callback issues with the 0.9.10 changes, and maybe 0.9.9 too, even though the tests pass with 0.9.9 because of the tests' assumptions around Backbone not changing its API.

The discussion in jeromegn/Backbone.localStorage#63 makes it seem like 0.9.9 and 0.9.10 each send different callback arguments from the previous versions.

dualStorage is not currently consistent with the arguments it sends to its callbacks, varying on the method and storage backend. I think the way forward is to maintain compatibility with older versions of backbone and to follow Backbone and standardize the callback arguments this library sends back.

from backbone.dualstorage.

nilbus avatar nilbus commented on August 20, 2024

1.0.0 just came out. Let's shoot for compatibility with 1.0.0 and the earlier versions of backbone that we already support.

from backbone.dualstorage.

evantishuk avatar evantishuk commented on August 20, 2024

Yeah, good policy. Would not be surprised if compatibility with 1.0.0 will also bring it into line with 0.9.9 and 0.9.10 as well--possibly fewer version checks (a la https://github.com/phoey/Backbone.localStorage/commit/bd34c367442f6854c0d5664425ec04c8108a69fe).

from backbone.dualstorage.

nilbus avatar nilbus commented on August 20, 2024

@globexdesigns Backbone 0.9.2 is bundled with Backbone.dualStorage in lib/

from backbone.dualstorage.

nilbus avatar nilbus commented on August 20, 2024

I examined the callback code for 0.9.2, 0.9.9, 0.9.10, and 1.0.0. These are the changes:

  • 0.9.2 starts with remote methods such as fetch, save, etc. that send the arguments (model, resp) to callbacks, and accept the standard $.ajax parameters (data, textStatus, jqXHR)/(jqXHR, textStatus, errorThrown) in its callbacks from sync.
  • 0.9.9 sends a 3rd options argument to the success and error callbacks given to remote methods like fetch. This doesn't affect us since we do not implement the remote methods like fetch.
  • 0.9.10 changes sync so that it calls the fetch(etc.) success/error callbacks with (model, resp/xhr, options), which allows those methods to call their callbacks with the same arguments. Sync gets resp/xhr from the first parameter in the $.ajax callback.
  • 1.0.0 changes sync back to how it was in 0.9.2, passing the $.sync callback parameters directly into the fetch(etc.) callbacks. However now the fetch(etc.) callbacks accept only the first argument (resp/xhr). This means that Backbone.sync (and its substitutes) no longer have have the responsibility of converting the $.ajax callback params to the new 0.9.10 fetch callback args. Since sync sends the same first argument again that 0.9.2 and earlier expected in the remote methods, it's much more backward compatible than 0.9.10 was.

from backbone.dualstorage.

nilbus avatar nilbus commented on August 20, 2024

Thanks @evantishuk for reporting this

from backbone.dualstorage.

evantishuk avatar evantishuk commented on August 20, 2024

Don't thank me, you did all the work. Thanks for addressing it. I like your solution.

from backbone.dualstorage.

nilbus avatar nilbus commented on August 20, 2024

This code snippet causes the fix to fail on Backbone 0.9.10:

var Model = Backbone.Model.extend({
    url: '/test',
    remote: false,
    local: true,
    success: function() {},
    error: function() {}
});

var model = new Model({name: 'test'});
model.save();
model.save({name: 'asd'});
model.save({name: 'asd3'});
model.save({name: '234234'});
console.log(model.attributes);

TypeError: Cannot call method 'call' of undefined at:

Developer Tools - http___lo_3000_

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.