mirror of
https://github.com/lxsang/antd-web-apps
synced 2024-11-20 18:28:22 +01:00
25 lines
637 B
CoffeeScript
25 lines
637 B
CoffeeScript
|
class BaseObject
|
||
|
constructor: (@name) ->
|
||
|
|
||
|
ready: () ->
|
||
|
me = @
|
||
|
return new Promise (r, e) ->
|
||
|
me.resolveDep()
|
||
|
.then () -> r()
|
||
|
.catch (m, s) -> e(m, s)
|
||
|
|
||
|
resolveDep: () ->
|
||
|
me = @
|
||
|
return new Promise (r, e) ->
|
||
|
dep = window.classes[me.name].dependencies
|
||
|
r() unless dep
|
||
|
|
||
|
fn = (l, i) ->
|
||
|
return r() if i >= dep.length
|
||
|
require(l[i])
|
||
|
.then () -> fn(l, i + 1)
|
||
|
.catch (m, s) -> e(m, s)
|
||
|
fn dep, 0
|
||
|
|
||
|
makeclass "BaseObject", BaseObject
|
||
|
|