Search code examples
androidmosby

Make intents that needs more than one arguments?


In mosby and in examples, the intent methods in the view takes one argument at most. How do I pass more than 1 arguments to interactor through a presenter?


Solution

  • You have to wrap your paramaeters into a class like this:

    class MyParams {
      final int a;
      final String b;
    
      MyParams(int a, String b){
        this.a = a;
        this.b = b;
      }
    }
    

    This is because in Rx Observable<T> takes exactly 1 Generic Type Argument.

    Then your View has some intent like

    interface MyView {
      Observable<MyParams> fooIntent();
    }
    

    There is also a class android.support.v4.util.Pair one could use if you have exactly 2 parameters.