NylasEnvConstructor

Summary

NylasEnv global for dealing with packages, themes, menus, and the window.

The singleton of this class is always available as the NylasEnv global.

Instance Methods

reportError()

report an error through the `ErrorLogger` Takes an error and an extra object to report. Hooks into the `onWillThrowError` and `onDidThrowError` callbacks. If someone registered with `onWillThrowError` calls `preventDefault` on the event object it's given, then no error will be reported. The difference between this and `ErrorLogger.reportError` is that `NylasEnv.reportError` will hook into the event callbacks and handle test failures and dev tool popups.

onDidBeep(callback)

Invoke the given callback whenever beep is called.

Parameters

Argument Description
callback {Function} to be called whenever beep is called.

Returns

Return Values
Returns a {Disposable} on which `.dispose()` can be called to unsubscribe.

onWillThrowError(callback)

Invoke the given callback when there is an unhandled error, but before the devtools pop open

Parameters
Argument Description
callback {Function} to be called whenever there is an unhandled error

Returns

Return Values
Returns a {Disposable} on which `.dispose()` can be called to unsubscribe.

onDidThrowError(callback)

Invoke the given callback whenever there is an unhandled error.

Parameters
Argument Description
callback {Function} to be called whenever there is an unhandled error

Returns

Return Values
Returns a {Disposable} on which `.dispose()` can be called to unsubscribe.

trace()

Run the Chromium content-tracing module for five seconds, and save the output to a file which is printed to the command-line output of the app. You can take the file exported by this function and load it into Chrome's content trace visualizer (chrome://tracing). It's like Chromium Developer Tools Profiler, but for all processes and threads.

inDevMode()

Is the current window in development mode?

inSafeMode()

Is the current window in safe mode?

inSpecMode()

Is the current window running specs?

getVersion()

Get the version of N1.

Returns
Return Values
Returns the version text {String}.

isReleasedVersion()

Determine whether the current version is an official release.

getConfigDirPath()

Get the directory path to N1's configuration area.

getWindowLoadTime()

Get the time taken to completely load the current window. This time include things like loading and activating packages, creating DOM elements for the editor, and reading the config.

Returns
Return Values
Returns the {Number} of milliseconds taken to load the window or null if the window hasn't finished loading yet.

close()

Close the current window.

getSize()

Get the size of current window.

Returns
Return Values
Returns an {Object} in the format `{width: 1000, height: 700}`

setSize(widthheight)

Set the size of current window.

Parameters
Argument Description
width The {Number} of pixels.
height The {Number} of pixels.

setSizeAnimated(widthheightduration)

Transition and set the size of the current window.

Parameters

Argument Description
width The {Number} of pixels.
height The {Number} of pixels.
duration The {Number} of pixels.

getPosition()

Get the position of current window.

Returns

Return Values
Returns an {Object} in the format `{x: 10, y: 20}`

setPosition(xy)

Set the position of current window.

Parameters
Argument Description
x The {Number} of pixels.
y The {Number} of pixels.

center()

Move current window to the center of the screen.

focus()

Focus the current window. Note: this will not open the window if it is hidden.

show()

Show the current window.

hide()

Hide the current window.

reload()

Reload the current window.

getWindowProps()

The windowProps passed when creating the window via `newWindow`.

onWindowPropsReceived()

If your package declares hot-loaded window types, `onWindowPropsReceived` fires when your hot-loaded window is about to be shown so you can update components to reflect the new window props. * callback: A function to call when window props are received, just before the hot window is shown. The first parameter is the new windowProps.

isMaximixed()

Is the current window maximized?

isFullScreen()

Is the current window in full screen mode?

setFullScreen()

Set the full screen state of the current window.

toggleFullScreen()

Toggle the full screen state of the current window.

beep()

Visually and audibly trigger a beep.

confirm(options)

A flexible way to open a dialog akin to an alert dialog.

Parameters

Argument Description
options An {Object} with the following keys:

Returns

Return Values
Returns the chosen button index {Number} if the buttons option was an array.

openDevTools()

Open the dev tools for the current window.

toggleDevTools()

Toggle the visibility of the dev tools for the current window.

executeJavaScriptInDevTools()

Execute code in dev tools.

results matching ""

    No results matching ""