Simple Question: Wait for atom to finish initalizing


#1

Hello!
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?


#2

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.


#3

Here is the code

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

The console.log statement is running.


#4

This is occurring during atom’s startup.


#5

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