Simple Question: Wait for atom to finish initalizing


I’m writing a package and am getting an error when the user first opens Atom because atom.workspace is not yet fully initialized.

Is there an event that gets called when atom.workspace is finished loading, or even when the atom window is finished loading? If so, I’d like to run my code when that event is fired.

Otherwise, how can I know when atom.workspace is initialized?


What is the error that you’re getting? As far as I’m aware, atom.workspace should always be available.

Also, it might help if you share some of the code.


Here is the code

if(!atom || !atom.workspace || !atom.workspace.onDidChangeActiveTextEditor) {
	atom.workspace.onDidChangeActiveTextEditor(function(editor) {
} else {
	console.log('Error something is not yet initialized)');

The console.log statement is running.


This is occurring during atom’s startup.


It would appear that your if/else statements are mixed up…if they’re all initialized the console.log statement will run.