Skip to content

Commit

Permalink
Update save method (#1)
Browse files Browse the repository at this point in the history
* update save method

add `immediate` option

* update changelog
  • Loading branch information
lozjackson authored Oct 11, 2016
1 parent 5bd0192 commit 2bc97dc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Change Log

* [#1](https://github.com/lozjackson/ember-auto-save/pull/1) Add `immediate` option to the `save()` method.

### v0.0.4 2016-08-15

* [BUGFIX] If the `model` has no `save` method, try `model.content`.
Expand Down
6 changes: 4 additions & 2 deletions addon/utils/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ const { assert, get } = Ember;
@method save
@param {Object} model The model to save
@param {Integer} time The time to wait before saving.
@param {Boolean} immediate Trigger the function on the leading instead
of the trailing edge of the wait interval. Defaults to false.
*/
export default function(model, time) {
export default function(model, time, immediate) {
if ( isNaN(time) || time < 0 ) { time = 2000; }
assert(`'model' should be an object`, typeof model === 'object');

Expand All @@ -66,5 +68,5 @@ export default function(model, time) {
}
assert(`'model.save' should be a function`, typeof model.save === 'function');

Ember.run.debounce(model, model.save, time);
Ember.run.debounce(model, model.save, time, immediate);
}

0 comments on commit 2bc97dc

Please sign in to comment.