![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
ampersand-optimistic-sync
Advanced tools
A sync wrapper for Backbone.sync and ampersand-sync that implements optimistic concurrency in HTTP.
A wrapper for Backbone.sync and ampersand-sync that implements optimistic concurrency over HTTP.
Not sure what optimistic concurrency is? You can read a bit more about it and implementing it in HTTP here.
For the default behavior, just extend like so:
var Model = require('ampersand-model'); // or require('backbone').Model;
var syncMixin = require('ampersand-optimistic-sync');
module.exports = Model.extend(syncMixin(Model));
Now your model will check for the ETag header on every request to the server.
If it exists, the ETag will be set on the model as _version and a sync:version (args: model, version) event will fire.
On updates, sync will now automatically include the _version value as an If-Match header.
If the update is successful, the new ETag that the server sends will be set as _version.
If the update request returns a 412 error, a sync:invalid-version (args: model, version, data)
event is fired.
The mixin takes an optional second config argument that can be used to modify behavior.
Allowed values; etag (default), last-modified
When config.type is changed to last-modified like so:
var Model = require('ampersand-model'); // or require('backbone').Model;
var syncMixin = require('ampersand-optimistic-sync');
module.exports = Model.extend(syncMixin(Model, {type: 'last-modified'}));
The model will now store Last-Modified header values as _version and send _version as an If-Unmodified-Since header.
If config.invalidHandler is a function, it will be registered as a sync:invalid-version
handler before your first update request is sent.
FAQs
A sync wrapper for Backbone.sync and ampersand-sync that implements optimistic concurrency in HTTP.
The npm package ampersand-optimistic-sync receives a total of 0 weekly downloads. As such, ampersand-optimistic-sync popularity was classified as not popular.
We found that ampersand-optimistic-sync demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.