Skip to content

Commit

Permalink
adding s-resource loader
Browse files Browse the repository at this point in the history
  • Loading branch information
eavichay committed Jan 2, 2017
1 parent 92f7ebe commit 32650f4
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions framework/components/basic-elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,16 @@ Slim.tag('s-resource', class extends Slim {
this.isLoading = false
}

handleError(err) {
let fnName = this.onerror || this.getAttribute('onerror')
if (typeof fnName === 'function') {
fnName(err)
} else if (typeof this._boundParent[fnName] === 'function') {
this._boundParent[fnName](err)
}
this.isLoading = false
}

load() {
this.isLoading = true
if (this.url) {
Expand All @@ -155,6 +165,9 @@ Slim.tag('s-resource', class extends Slim {
this.data = data
return this.data
})
.catch( err => {
this.handleError(err)
})
}
}

Expand Down

0 comments on commit 32650f4

Please sign in to comment.