Sublime Forum

How to get a reference to ApplicationCommand instance

#1

The documentation says that ApplicationCommand and WindowCommand are instantiated once per sublime instance and window, respectively. Whats the best way to get hold of that instance from, say, a TextCommand?

My use case is that I have a kind of data server running as an ApplicationCommand, which my TextCommands need to talk to every so often. At the minute I’m doing all this through static variables in the ApplicationCommand class, which is obviously not ideal.

0 Likes

#2

I don’t think that there’s any way to get at the actual instances of such classes via any Sublime API call, so I think you’d need to do that yourself from your own code like you’re doing now.

With that said, if ApplicationCommand is instantiated once per application you could communicate to the server by using sublime.run_command() to invoke the command that it implements and pass in arguments that control what you want it to do or something like that.

1 Like

#3

Hi!

I’m not sure you get the same instance (althought the opposite would be weird), but I do:

view.window()

It gets me a window instance from which I can do all this stuff

Matt

0 Likes