Giter Site home page Giter Site logo

Comments (15)

glennawatson avatar glennawatson commented on April 27, 2024 1

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.

glennawatson avatar glennawatson commented on April 27, 2024 1

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.

glennawatson avatar glennawatson commented on April 27, 2024 1

Hopefully the linked issue will solve your problem.

from reactiveui.

Metadorius avatar Metadorius commented on April 27, 2024

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.

glennawatson avatar glennawatson commented on April 27, 2024

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.

Metadorius avatar Metadorius commented on April 27, 2024

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.

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.

Metadorius avatar Metadorius commented on April 27, 2024

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.

glennawatson avatar glennawatson commented on April 27, 2024

The view resolution is the primary reason why IViewFor exists. It relies on the generic.

from reactiveui.

glennawatson avatar glennawatson commented on April 27, 2024

Anyway. There's no plan to introduce a non generic IViewFor.

from reactiveui.

Metadorius avatar Metadorius commented on April 27, 2024

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.

glennawatson avatar glennawatson commented on April 27, 2024

As mentioned we aren't doing any changes to the IViewFor.

from reactiveui.

Metadorius avatar Metadorius commented on April 27, 2024

As mentioned we aren't doing any changes to the IViewFor.

I am not asking to...

from reactiveui.

Metadorius avatar Metadorius commented on April 27, 2024

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.

Metadorius avatar Metadorius commented on April 27, 2024

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.

github-actions avatar github-actions commented on April 27, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.