Comments (15)
Some options I can think of you can do as a alternative to IViewFor<T>
Write your own resolver. You could probably scan for classes with a property named ViewModel
and determine the type from that.
If performance matters you can use a .NET source generator to do the scanning and put it into a nice dictionary inside a class. Probably will be faster lookup then the current RxUI implementation.
That way you can avoid the generic IViewFor
I don't think going down the route of having 'object' everywhere is a solution for the rxui code base though.
I'm tempted to do a optional component that does this one weekend from now. Won't be part of the main rxui though.
I'll create a separate issue to track the idea.
from reactiveui.
You want to use the non generic IViewFor for the command binders or a version of the command binders that doesn't use the IViewFor at all is my understanding.
You're asking for a fundamental change to the project where it's pretty stable.
from reactiveui.
Hopefully the linked issue will solve your problem.
from reactiveui.
One more thing. Same deal with ReactiveUserControl<TViewModel>
, we need a non-generic counterpart to it. It's very easy to craft one myself but would still be nice to have it out of the box.
from reactiveui.
We aren't likely to change the signatures in this scenario.
The advice is to generate a base class that's non-generic that implements IViewFor<T>
. Eg public MyFancyViewModelUserControlBase : ReactiveUserControl<MyFancyViewModel> { }
, then derive your view from that. You've got a class that accurately reflects your view model in this scenario.
We don't want a "object" based IView, it complicates a bunch of code for every other platform. It would force us to rely on more reflection then we already do. We been trying to minimise the amount of reflection used.
from reactiveui.
The advice is to generate a base class that's non-generic that implements
IViewFor<T>
. Egpublic MyFancyViewModelUserControlBase : ReactiveUserControl<MyFancyViewModel> { }
, then derive your view from that. You've got a class that accurately reflects your view model in this scenario.
Yeah this is a) blowing up the codebase with unnecessary meaningless code considerably, b) doesn't always work because as I said WinForms hate generics.
I in fact don't see why can't just changing signature of command binder methods to accept IViewFor
instead of the generic counterpart work, they pass it as IViewFor
without any generics? I already just do IViewFor<object>
and it seems to just work from a brief testing, albeit being a bit ugly?
from reactiveui.
Maybe I am using MVVM/RxUI wrong, but I personally don't use view resolution whatsoever. That's why I said "except the last one", I mean the command binder stuff only. View resolution should probably stay as is with requiring the generic counterpart.
from reactiveui.
The view resolution is the primary reason why IViewFor exists. It relies on the generic.
from reactiveui.
Anyway. There's no plan to introduce a non generic IViewFor.
from reactiveui.
I don't understand, I am just asking for a few methods which don't really require the IViewFor<TViewModel>
to just relax the too specific input parameter types, because the moment the next method in call stack gets called this generic version is not needed but non generic IViewFor
is needed. I don't ask to introduce any logic changes whatsoever, I just ask for command binder signatures to not be unnecessarily specific so I don't need a hack for it to work in my use case.
It seems like we're talking about different things.
from reactiveui.
As mentioned we aren't doing any changes to the IViewFor.
from reactiveui.
As mentioned we aren't doing any changes to the IViewFor.
I am not asking to...
from reactiveui.
Re-reading your replies, sorry but I don't feel you ever understood what my request really is and just shot it down :\
from reactiveui.
You want to use the non generic IViewFor for the command binders or a version of the command binders that doesn't use the IViewFor at all is my understanding.
Yes, that is what I wanted.
Hopefully the linked issue will solve your problem.
Yes. Thanks much and sorry for getting worked up!
from reactiveui.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
from reactiveui.
Related Issues (20)
- [Bug]: Accessibility properties SizeOfSet and PositionOfSet are not being set when using <ReactiveWindow> HOT 6
- [Bug]: ReactiveUI incompatible with .NET Assembly Load Contexts HOT 2
- [Bug]: On Maui initial NavigateAndReset pushes the same screen twice HOT 8
- Add overloads for the command binders that accept IViewFor HOT 1
- [Bug]: got imcompatible message when using with .net 7 HOT 2
- [Bug]: Visual Studio hot reload broken HOT 21
- [Bug]: Putting RoutedViewHost inside a TabControl on Avalonia causes an app crash after navigating the second time HOT 7
- [Bug]: `ObservableAsPropertyHelper` emits property changed for lazy initial value after first-time reading and doesn't respect `DistinctUntilChanged` HOT 1
- [Bug]: WPF ReactiveCommand stays disabled after first execution HOT 9
- [Bug]: Mark ReactiveObject IObservable properties with DisplayAttribute for Winforms HOT 9
- ReactiveUI.WPF does not include .net 8.0 as a target: HOT 3
- [Bug]: Unable to use activation of views on Windows with MAUI HOT 2
- ViewModelViewHost: Better to Allow Developers Bypass the Default Fallback Behavior That Resovles View With No Contract HOT 2
- [Bug]: WireUpControls throws exception in net8.0-android HOT 8
- [Bug]: ViewModelViewHost does not set DataContext in WPF HOT 2
- [Bug]: WPF targeting issue for net6.0-windows HOT 4
- Dependency Dashboard
- [Bug]: iOS threading exception on command execution. HOT 4
- Bounce transition duration support HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reactiveui.