Search…
⌃K

@listener

This decorator register class method as listener in eventrix.
useEventrix" decorator is required if You want use any of eventrix decorators.
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;
Below example of code without decorators.
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;