Giter Site home page Giter Site logo

Routing API revamp RFC about sextant HOT 3 OPEN

reactiveui avatar reactiveui commented on April 20, 2024
Routing API revamp RFC

from sextant.

Comments (3)

kentcb avatar kentcb commented on April 20, 2024

👍 A lot of this is in line with my thoughts on re-vamping routing, perhaps for V8. However, I'd prefer stack semantics for NavigationStack members, such as Push and Pop.

But that's pretty much irrelevant minutia right now. I think the important thing is to take routing in a direction that gives us:

  • far greater consistency across platforms (by sharing far more code and pushing more responsibility into that shared code)
  • far greater flexibility (not dictating so much about how routing occurs at the UI level)
  • a story for platforms that aren't VM-first friendly (e.g. Android)

These are difficult problems to solve, and I think we should look for inspiration elsewhere (Prism, MVVMCross etc).

from sextant.

qrzychu avatar qrzychu commented on April 20, 2024

When revamping navigation, I would also like something like Router.PushDialog.

This is a common scenario (I think), when I want edit an item in another ViewModel and then fall back to previous VM with new value.

Rigth now I use some hacks like this:

 EditItem = ReactiveCommand.CreateFromObservable<Item, Item>(item =>
            {


                var editVM = new EditItemViewModel(HostScreen, resolver, item);
                HostScreen.Router.Navigate.Execute(editVM).Subscribe();

                
               
                return HostScreen.WhenAnyValue(x => x.CurrentViewModel)
                        .Where(x => x == this)
                        .Take(1)
                        .TakeUntil(HostScreen.Router.NavigationStack.ShouldReset)
                        .Select(x => item);

                // or use EditDone command of EditVM

                return editVM.EditDone.Select(x => item)
                       .Take(1)
                       .TakeUntil(HostScreen.Router.NavigationStack.ShouldReset); 
                 // and navigate back in EditItem.Subscribe
});

I think that with NavigationStack it would be great to write something like this:

return HostScreen.Router.PushDialog.Execute(editVM).Select(x => item);

PushDialog would return editVM when Router.Pop would bring us back to CurrentViewModel and handle all edge cases of navigating to terminate returned observable.

It's quite easy to make an extension method for that, but if you want to revamp the whole thing either way, it could be just built-in functionality.

If there is already a easy way to make it error free, please tell me :)

from sextant.

glennawatson avatar glennawatson commented on April 20, 2024

Assigning to @RLittlesII I know he's been wanting to get his feet dirty on this type of thing.

from sextant.

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.