Created
November 3, 2017 03:47
-
-
Save RickButler/cb7fd02c74d21267a1ca2481b8bf9503 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var AmpersandModel = require('ampersand-model'); | |
var get = require('lodash/get'); | |
var includes = require('lodash/includes'); | |
AmpersandModel.extend({ | |
session: { | |
fetched: 'boolean', | |
saved: 'boolean', | |
destroyed: 'boolean' | |
}, | |
constructor: function () { | |
this.on('sync', function (opts) { | |
if (get(opts, 'xhr.method') == "GET") { | |
this.fetched = true; | |
} | |
}, this); | |
this.on('destroy', function (opts) { | |
this.destroyed = true; | |
}, this); | |
this.on('sync', function (opts) { | |
if (includes(["POST", "PUT", "PATCH"], get(opts, 'xhr.method'))) { | |
this.saved = true; | |
} | |
}, this); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment