How to inject a service in discourse?

Yes you can do that. lookup appEvents.trigger