Git Product home page Git Product logo

Comments (9)

jspahrsummers avatar jspahrsummers commented on April 28, 2024

Other ViewModel responsibilities not clear for me. Who manages UINavigationController stack?

In response to changes in the view model, the view layer will present or pop view controllers.

As a general rule of thumb, the view model should not use anything from UIKit. This isn't always possible, but it's a good guideline.

This system will allow to test and isolate application not just by parts, but also by task, user stories, and other logical chunks.

I'm not really familiar enough with DCI to comment on this.

  1. Common Shared state between ViewModels (network clients, core data contexts)
  2. Container View Controllers responsibility.

What exactly are your questions here?

from reactiveviewmodel.

oleksii-demedetskyi avatar oleksii-demedetskyi commented on April 28, 2024

In response to changes in the view model, the view layer will present or pop view controllers.

For example. In app we have 2 screens. List of some items, and item details.
User select some row.

  1. Table transfer control to its delegate, (typically controller)
  2. Controller change some property of ViewModel ( selectedItem for example) (is it correct?)
  3. View Model react and .. what? Change another property? Fire some event to the signal?
  4. Some how control flow goes back to controller - now controller need to instantiate next controller, push it to navigation.. But for this action controller need to create another controller's ViewModel, and some how link them with actual model. All this stuff is out of view competence, so i am sure there is error in my thoughts.

1.Common Shared state between ViewModels (network clients, core data contexts)

How common dependency traverse between view models? From one to another? then how transitive dependency solved? I mean:

A -> B -> C, where {A require D1, B require D2, C require D1}

from reactiveviewmodel.

jspahrsummers avatar jspahrsummers commented on April 28, 2024
  1. Controller change some property of ViewModel ( selectedItem for example) (is it correct?)

Yep.

  1. View Model react and .. what? Change another property? Fire some event to the signal?

Yes, exactly.

For example, the current view model may have a detailViewModel property. Changing that property will notify the VC that a new view controller should be pushed onto the navigation stack.

How common dependency traverse between view models? From one to another? then how transitive dependency solved?

This isn't a problem unique to VMs. Like you would do anywhere else, you can use dependency injection, or just pass to B the data that C will eventually need.

from reactiveviewmodel.

oleksii-demedetskyi avatar oleksii-demedetskyi commented on April 28, 2024

Great Thanks for your time and explanations!
Now it is much more clear to me.

from reactiveviewmodel.

jspahrsummers avatar jspahrsummers commented on April 28, 2024

No problem!

from reactiveviewmodel.

fatuhoku avatar fatuhoku commented on April 28, 2024

How might one use ReactiveCocoa to pass data between ViewControllers?

I know that the typical way people do this is

  • pass data forward by
    • init-injecting data into next VC
    • setter-injecting data into the destinationViewController in prepareForSegue: when using storyboards
  • pass data backward by having the previous view controller implement a delegate

Can ReactiveCocoa be used to streamline the way data is passed to and from view controllers?

from reactiveviewmodel.

kastiglione avatar kastiglione commented on April 28, 2024

Instead of having controllers communicate back via a delegate, declare a signal (or property) on the controller and have the invoking controller subscribe to that signal/property.

from reactiveviewmodel.

bangerang avatar bangerang commented on April 28, 2024

I'm also interested in passing data between ViewControllers with ReactiveCocoa. Could you share som example code? Let's say we have a UITableViewController and a DetailViewController. If I tap a cell in the UITableViewController how can pass along data based on the tap to the DetailViewController?

from reactiveviewmodel.

jspahrsummers avatar jspahrsummers commented on April 28, 2024

@bangerang You can create the next view controller by passing a view model to its initializer, or just set a property, like in @ashfurrow's C-41 project.

from reactiveviewmodel.

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.