setValueWithOrigin cause Infinite Loop

Hi,

I’m trying to create a number input that will add thousand separator whenever the value on text input reach more than thousand with Observable and setValueWithOrigin, below is the code

function formatNumber(number, delimiter, decimalDelimiter){
	var numberString = number.toString(),
		splitNumber = numberString.split('.'),
		splitFloats = '';

	// Check if the number's precision is greater than the thousanths place.
	// If so, build out the tail end of the formatted Number.
	if(splitNumber[1] && splitNumber[1].length > 3) {
		splitFloats = decimalDelimiter + number.toFixed(3).toString().split('.')[1];
	}

	return splitNumber[0].split( /(?=(?:\d{3})+$)/g ).join(delimiter) + splitFloats;
}

var Amt = Observable("0")
Amt.addSubscriber(function(obs, op, val, origin){
	console.log("origin : "+origin)
	if (origin == 12345) return

	v = val.split(',').join('')
	fnum = formatNumber(parseInt(v),',','.')
	obs.setValueWithOrigin(fnum, 12345)
	return
			
})

At first, when the input value is below 1000, the function is executed normally, but once the function start adding thousand separator, then it’s triggering infinite loop

It seems the infinite loop is caused by same variable (Amt) is bind to two text input, after separate the variable (each text input bind to different variable) the above code is working as expected. Thanks