meta-next
Version:
57 lines (50 loc) • 845 B
JavaScript
import Resources from "./Resources"
class Resource
{
constructor(config) {
this._loaded = false
this._loading = false
if(config) {
this.setup(config)
}
}
set loaded(value)
{
if(value) {
if(!this._loaded) {
this._loaded = true
this.loading = false
}
}
else {
if(this._loaded) {
this._loaded = false
}
}
}
get loaded() {
return this._loaded
}
set loading(value)
{
if(value) {
if(!this._loading) {
this._loading = true
this._loaded = false
Resources.resourceLoading(this)
}
}
else {
if(this._loading) {
this._loading = false
this._loaded = true
Resources.resourceLoaded(this)
}
}
}
get loading() {
return this._loading
}
}
Resources.Resource = Resource
export default Resource