You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to check if the typed username already exists in the database. I've got an async query, but i don't want to check it after every typed character but 1s after typing finished.
this.ValidationRule(x => x.Username, x => !this.IsUsernameExists, "Username already exists.");`
The problem is, when Username changed, the validation evaulates IsUsernameExists before it is updated because the delay. So the validation is always 1 character behind typing.
Does anyone know a solution for the problem?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I want to check if the typed username already exists in the database. I've got an async query, but i don't want to check it after every typed character but 1s after typing finished.
Here is what i've got so far:
`
[Reactive]
public string? Username{ get; set; }
[ObservableAsProperty]
public bool IsUsernameExists{ get; }
...
this.WhenAnyValue(x => x.Username)
.Throttle(TimeSpan.FromMilliseconds(1000)
.Select(x => this.UserNameExists.ExecuteAsync(x))
.Select(x => x.Result)
.ToPropertyEx(this, vm => vm.IsUsernameExists);
this.ValidationRule(x => x.Username, x => !this.IsUsernameExists, "Username already exists.");`
The problem is, when Username changed, the validation evaulates IsUsernameExists before it is updated because the delay. So the validation is always 1 character behind typing.
Does anyone know a solution for the problem?
Thanks in advance,
Imre Horvath
Beta Was this translation helpful? Give feedback.
All reactions