Custom ui node beforeemit (i want to get ideas)

I am preparing a custom ui node. In this node, I want to process the data on the ui side as soon as the data comes from the socket, but in the beforeemit property, it is triggered only when data from another node arrives. In what other way can I use this data live on the ui side?

var done = ui.addWidget({
            node: node,
            order: config.order,
            beforeEmit: function(msg){
              //it is triggered
            initController: function(){}
node.server.getListenSocketData().thenAgain((data) => {
            try {
                if (data) {
                    var resultModel = JSON.parse(data)
                    if ( == {

                        node.send({ payload: node.buttonValue })
            } catch (err) {