How to attach js in services? Here is my code:

services file

  services:
  my_module.event_subscriber:
    class: Drupal\my_module\EventSubscriber\My_moduleSubscriber
    arguments:
      - '@authentication'
      - '@current_user'
    tags:
      - {name: event_subscriber}


My_moduleSubscriber.php

 &lt;?php

  public function xyz) {
  // I want to attach js here
  $attachement['#attachement'][js] = .....
//    drupal_add_js(libraries_get_path('audio-player').'/audio-player.js');

  }

  static function getSubscribedEvents() {
    $events[KernelEvents::RESPONSE][] = array('xyz');
    return $events;
  }


Since there is no argument passed like $attachement, $page, in which variable should i attach js file in Drupal?
A response event is possibly too late, I think at that point, you already have a built response object, and the page is just a string that will be replaced.

You're better of using a hook for this, namely hook_page_attachments(), which exists just for the purpose of adding additional libraries to the page.