✅ Index expressions are only supported with constants - Avalonia ReactiveUI
I keep getting a run-time error (only shows up when I attempt to launch the application) that says
Index expressions are only supported with constants
on the IObservable<bool>
and I'm not quite understanding why and google doesn't offer much help.14 Replies
do not reuse
x
for onewhat do you mean?
https://www.reactiveui.net/docs/handbook/commands/
That's how the library shows to use it
I assume this is for CanExecute?
correct
https://www.reactiveui.net/docs/handbook/when-any#reactivecommandcanexecute-observable
I have rarely ever used ReactiveUI, but I assume you cannot use an instance of an object, the method in question must be static
so then it would be something like this? Which I mirrored from https://www.reactiveui.net/docs/handbook/when-any#reactivecommandcanexecute-observable
Pretty much, yeah.
ok bet. tyvm. you just helped me save lines of code on other projects that do multiple IObservables and then concat then all together ❤️
Also good to add DistinctUntilChanged
So it does not spam you
This operator stands guard, ensuring that you're not bombarded with repetitive information. Imagine if your best friend kept repeating the same story to you every time you met. It'd get old, right? The DistinctUntilChanged operator does just that; it prevents subsequent identical emissions from an observable.
ok where do I put it?
at the end of the WhenAnyValue method call
Buddy
Quoted by
<@203166497198047232> from #✅ Index expressions are only supported with constants - Avalonia ReactiveUI (click here)
React with ❌ to remove this embed.
docs here links to the example that shows you how to call it
I see it. tyvm ❤️