How can I use hook_views_query_alter()? How can I implement hook_views_query_alter() in Drupal 8? 

In Drupal 7, I could use the following code.

$args = arg;
$node = menu_get_object();

if ($args[0] === 'my_view') {
  $query-&gt;orderBy('node_field_data_created','ASC');
  if (!empty($node) &amp;&amp; $node-&gt;type == 'category') {
        $filters = $query-&gt;getFilters();
        $first_filter = $filters[0];
        if ($first_filter['#value'] == "(category) AND node_field_data.status:(1)") {
            $query-&gt;condition('field_category', $node-&gt;nid, '=');
        }


In Drupal 8, this code doesn't work. 

Can anyone help me out?
According to the documentation page for hook_views_query_alter(), this hook works in Drupal 8, but (as you can see in comments for the referenced article) you should place it in mymodule.views_execution.inc, not in mymodule.module.