uber / uber/RIBs

[iOS] Dependency(?) injection after Router has been created.

Open
#303 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

iOS
Dominant language
Kotlin
Stars
7.9k
Forks
914
PR merge metrics
No merged PRs in 30d

Description

From the tutorials it seems that the dependencies must be passed in to a child rib before you are ready to display said child Rib. What is the convention for passing data that will be needed by the child rib that is entered into (i.e: a textfield) the parent rib?

For example:
-Rib A has a spinner picker that lets you pick one of 3 types (an address, a contact or a credit card) and a button that triggers Rib B.
-Rib B displays a view to add an object of the type selected in Rib A.
(Rib A is a table view with a cell that contains a text field for each component of the object type selected in Rib A)
-How should that type be passed from Rib A to Rib B? The builder for Rib B which takes in the dependency/component is created when Rib A is created/displayed as this is done when Rib A's router is created. This is done before the user has selected a Type.
Note: Trying to find a solution without Rx as our dev team is mainly comprised of junior developers and converting the project to Rx would add a lot of complexity that I don't think our team is ready to handle yet.

My current solution is to still create the builder for Rib B when Rib A's router is created however I pass the needed type through the protocol methods to Rib A's router and modified the .build() function to also take in that type which can then be passed to Rib B's interact and used to setup Rib B. However this feels like I'm passing in dependencies in two spots and doesn't seem like the ideal design, although it does work. This will become ugly if there are multiple values that need to be passed between views and would end up creating another "dependency" type object to pass to the child Rib.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the tutorials and the Rib A/Rib B builder, router, dependency, and interactor flow described in the issue. Determine how data selected after router creation is conventionally passed without Rx, and document the recommended approach, including how multiple values should be handled.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios
Domain
mobile-dev
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.