[SOLVED] Auto triggering package


#1

Hi there,

I’m sorry if this is a duplicate but I couldn’t find a proper answer.

I’m coding https://github.com/iSheeft/char-count which counts the number of characters selected.
But it requires to be triggered through the palette.

I tried through copying to achieve that but I couldn’t find how.

Any help would be welcome. Thanks !


#2

You just need to remove the activationEvents key from your package.json:

You can take a look at my Tabs to Spaces package for an example of loading on startup, but deferring full loading until a feature is actually used.


#3

Thanks a lot.

Now it does launch at startup but it no longer works :

Failed to activate package named 'char-count' TypeError: Cannot call method 'prependRight' of undefined

How can it be ? Does the package loads too fast for the statusbar to be already opened ?

Thank you.


#4

This is quite possible, the status-bar being also a package, and most of the package loading being done asynchronously you can’t really rely on another package being activated when your own package receive the activation call.

If you look at the grammar-selector package it seem it use a specific event to be notified when all packages have been activated:

atom.packages.once('activated', createGrammarStatusView)

It’ll probably help you solve your issue.


#5

Thanks, it indeed dit the trick !