toLowerCase function stoped working after update to 0.35.0

code worked fine on .29 (version i run before updating) but on .35 it crashes the app don’t know why looks like its looping the function…?

		makeLowerCase = function(obs, op, arg, origin){
		  if (origin === makeLowerCase) return;
		  username.setValueWithOrigin(username.value.toLowerCase(), makeLowerCase);
		};
		username.addSubscriber(makeLowerCase);

Hi! That’s unfortunate.

Can you please upload an example project that reproduces this (that works in 0.29 but not in 0.35) ?

toLowerCase is a built-in function in the JavaScript language/standard lib, so its very unlikely that the actual issue is that the API disappeared. Probably something else specific to your project.

Hi Anders

getting the same results with this bit of code:

	<App>
		<ClientPanel>

			<JavaScript>
				var Observable = require("FuseJS/Observable");
				var username = Observable("");


				makeLowerCase = function(obs, op, arg, origin){
				  if (origin === makeLowerCase) return;
				  username.setValueWithOrigin(username.value.toLowerCase(), makeLowerCase);
				};
				username.addSubscriber(makeLowerCase);


				module.exports = {
					'username': username
				}
			</JavaScript>


			<StackPanel ux:Name="loginForm" Alignment="Center" Margin="50,0,50,0" Width="300">
				<TextInput ux:Name="emailText" PlaceholderText="username" Value="{username}">
				    <Rectangle Dock="Bottom" Height="2" Margin="0" Fill="#f5b5a5" Opacity="0.7" />
				</TextInput>
			</StackPanel>

		</ClientPanel>
	</App>

It Just goes mad and prints ‘Log: expected number was Fuse.Scripting.V8.Function’ 1000x a second…

Kevin: The setValueWithOrigin method is not documented and doesn’t work the way your code implies.

Generally, you writing back to an observable in response to the user changing the value is not a good pattern, as this is asynchronous and leads to erratic beahvior.

You can do this, however it relies on another non-public API and is subject to change in the future:

var selfOrigin = Observable._createOrigin()
makeLowerCase = function(obs, op, arg, origin){
    if (origin === selfOrigin) return;
    username.setValueWithOrigin(username.value.toLowerCase(), selfOrigin);
};
username.addSubscriber(makeLowerCase);

Use at your own risk