Access tree view API

Using the instructions at https://github.com/atom/tree-view#api, is not working for me.

I just get a message that ‘treeView is not defined’, so I guess I have to import it? But from where?

You shouldn’t have to import it because it’s passed to your consuming function.

In order for us to troubleshoot your code, you first need to share it. Please post a link to a GitHub repo or similar where we can take a look at what you’re doing.

Thanks, but I solved it, I was running this.consumeTreeView(treeView) inside the activate method. Removed this, and It worked:)

@johann1301h Services are async and handled by Atom, because the whole point is there may not be a service available. The consuming method declared in the package.json file will be called with the payload argument automatically when Atom determines there is a loaded package to provide the service.

when Atom determines there is a loaded package…

So there is no way to really know when the api is available? May be after or before the activation?

Correct; a service is provided by another package. If the user does not have such a package, the service will not be available, and you cannot consume it. If you wish to delay something until the service is available, run it in the consumption method.