How to override remove method of repeat element and perform both operations of removing and adding some logic in ngx formly angular

I am using a repeat field in which there is a remove button this works fine normally, but my requirement is to perform some logic while removing the element for which I will call a customize function onRemove instead of remove(i), could anyone help me to achieve this, following is the stackblitz demo: Click here stackblitz demo

code snippet for removing element in formlytype component :

<button class="btn btn-danger" type="button" (click)="remove(i)">Remove

Source: Angular Questions