Git Product home page Git Product logo

Comments (3)

ashfurrow avatar ashfurrow commented on April 29, 2024

There are a couple of different approaches you can take. First, the view model shouldn't be the data source of the table view, but rather the view controller should ask the view model for things like number of rows, etc. I would have a selection property on the view model that is bound to the selected index of the segmented control using ReactiveCocoa. Then whenever that selection changes, reload the table view. Finally, depending on the selection property, the view model will return different data.

Hope that helps – let me know if you'd like any clarification. Also, this is just how I would approach this problem. Feel free to experiment!

from reactiveviewmodel.

talesp avatar talesp commented on April 29, 2024

So the view controller should still be the data source (as a delegate, being a UITableViewController subclass (not my case) or via -[RACSignal rac_signalForSelector:fromProtocol:]) of the table view, instead of turning the view model as the data source? I thought letting the view model be the data source would be a better approach, but looking at your FunctionalReactivePixels, the galley, for example, is a UICollectionViewController subclass.

I'll experiment and return this after that. Thank you

from reactiveviewmodel.

jspahrsummers avatar jspahrsummers commented on April 29, 2024

Generally, view models should not interact with the UI framework at all. Becoming a UITableViewDataSource requires knowledge of UITableViewCell, which isn't appropriate for the view model.

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.