From: Cheng Zhao Date: Wed, 14 Jan 2015 00:27:58 +0000 (-0800) Subject: Don't hard-code API names X-Git-Tag: v0.20.7~10^2~10 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=509294b228daab1c4c33ec0e94ecbd52757493c1;p=electron.git Don't hard-code API names --- diff --git a/atom/common/api/lib/screen.coffee b/atom/common/api/lib/screen.coffee index e2913fcb..bef5649d 100644 --- a/atom/common/api/lib/screen.coffee +++ b/atom/common/api/lib/screen.coffee @@ -4,14 +4,12 @@ checkAppIsReady = -> unless process.type is 'renderer' or require('app').isReady() throw new Error('Can not use screen module before the "ready" event of app module gets emitted') -module.exports = - if process.platform in ['linux', 'win32'] and process.type is 'renderer' - # On Linux we could not access screen in renderer process. - require('remote').require 'screen' - else - getCursorScreenPoint: -> - checkAppIsReady() - binding.getCursorScreenPoint() - getPrimaryDisplay: -> - checkAppIsReady() - binding.getPrimaryDisplay() +if process.platform in ['linux', 'win32'] and process.type is 'renderer' + # On Linux and Windows we could not access screen in renderer process. + module.exports = require('remote').require 'screen' +else + for name, _ of binding + do (name) -> + module.exports[name] = (args...) -> + checkAppIsReady() + binding[name](args...)