Skip to content

Commit

Permalink
rudimentary loading indicator for sync
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Lasky committed Mar 17, 2016
1 parent 2140198 commit 0823ec6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/mm-sync/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@
<template>
<mm-checkbox checked="{{allow}}"><label>Allow</label></mm-checkbox>
<mm-input value="{{autoTest}}"></mm-input><span>{{autotest}}</span>
<mm-sync endpoint="http://localhost:8000/ajax" data="{{zippy}}">
<template is="dom-if" if="{{isLoading}}">
<span>Is Loading!</span>
</template>
<mm-sync endpoint="http://localhost:8000/ajax" data="{{zippy}}" is-loading="{{isLoading}}">
<GET>
<queryParam name="q" value="ui.*" conditional if$="{{allow}}"></queryParam>
<queryParam name="user">userInnerVal</queryParam>
Expand Down
10 changes: 10 additions & 0 deletions src/shared/js/sync.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@

scope.Sync = function(endpoint, options, data, domHook, saveResponse, plugins) {
this._eventPrefix = _eventPrefix;
this.isLoading = false;
this.endpoint = this.endpoint || endpoint || "/";
this.options = DataUtils.copy({
contentType:"application/x-www-form-urlencoded",
Expand Down Expand Up @@ -146,6 +147,8 @@
promise = this._ajax.exec(null, options);
}

this.isLoading = true;

promise.then(this._handleResult.bind(this), this._handleError.bind(this));

return promise;
Expand All @@ -155,6 +158,7 @@

this.fire("ready", result, {prefix:true});

this.isLoading = false;
result = this._plugin.processResponse(result);

if (this.saveResponse) {
Expand All @@ -169,6 +173,7 @@
},

_handleError: function(error) {
this.isLoading = false;
this.fire("error", error, {prefix:true});
},

Expand Down Expand Up @@ -223,6 +228,11 @@
saveResponse:{
type:Boolean,
value:true
},
isLoading:{
type:Boolean,
value:false,
notify:true
}
},
created: function() {
Expand Down

0 comments on commit 0823ec6

Please sign in to comment.