Nam Thai Nam Thai - 1 year ago 49
Javascript Question

rome.js value change callback?

I have this datetime picker with rome.js.
I'm looking for a callback whenever I pick a new date. According to the documentation, these types of events emit using a library named

. However, I am on the client side, so node.js doesn't really work. How do I subscribe to these events?


There's no reason you'd need node for this: node comes with the EventEmitter utility built-in, but it's perfectly possible to implement an event emitter outside of node, which is exactly what the contra library has done.

The following code will run fine in the browser:

var datePicker = rome(element, romeOptions);
datePicker.on('data', (newDate) => {