Add on_data_write event handler.