# @listener

This decorator register class method as listener in eventrix.

{% hint style="info" %}
useEventrix" decorator is required if You want use any of eventrix decorators.
{% endhint %}

{% tabs %}
{% tab title="Javascript" %}
```javascript
import React from 'react';
import { useEventrix, listener } from 'eventrix';

@useEventrix
class ClientsService {
    constructor(services) {
        this.counter = 0;
    }

    @listener('Clients:create.success')
    createCounter(eventData) {
        this.counter ++;
        console.log(this.counter)
    };
}

export default ClientsService;
```
{% endtab %}
{% endtabs %}

Below example of code without decorators.

{% tabs %}
{% tab title="Javascript" %}
```javascript
import React from 'react';

class ClientsService {
    constructor(services) {
        this.eventrix = services.eventrix;
        this.eventrix.listen('Clients:create.success', this.createCounter);
    }

    createCounter = (eventData) => {
        this.counter ++;
        console.log(this.counter)
    };
}

export default ClientsService;
```
{% endtab %}
{% endtabs %}
