title: Flutter Bloc Rx dart combineLatest2 combine function not running
body: <p>I'm writing a flutter app and and using the bloc library. I have a bloc and a cubit, within the state of each is a list of ids of some other documents I need to fetch from firestore. There can be some overlap and some docs are already fetched so I want to get the list of ids from both states, compare them, and then only go to firestore for ones that exist in one but no the other.</p>
  <p>I set a new cubit for this:</p>
  <pre><code>class CircleRecipesCubit extends Cubit&lt;CircleRecipesState&gt; {
    CircleRecipesCubit({
      @required RecipesBloc recipesBloc,
      @required CirclesCubit circlesCubit,
    })  : assert(
            recipesBloc != null,
            circlesCubit != null,
          ),
          _recipesBloc = recipesBloc,
          _circlesCubit = circlesCubit,
          super(CircleRecipesInitial());
  
    final RecipesBloc _recipesBloc;
    final CirclesCubit _circlesCubit;
  
    StreamSubscription _recipesSubscription;
    StreamSubscription _circlesSubscription;
  
    Future&lt;void&gt; getCircleRecipes() async {
      // get a list of recipes the user already has loaded
      List&lt;String&gt; userRecipesIds;
      _recipesSubscription = _recipesBloc.stream.listen((RecipesState event) {
        if (event is RecipesLoaded) {
          userRecipesIds = event.recipes.map((e) =&gt; e.id).toList();
          print('*');
          print(userRecipesIds);
          print('*');
        }
      });
  
      // get a list of recipes in the circles
      List&lt;String&gt; circleRecipeIds;
      _circlesSubscription = _circlesCubit.stream.listen((CirclesState event) {
        if (event is CirclesLoaded) {
          circleRecipeIds = event.circles.fold([],
              (previousValue, element) =&gt; [...previousValue, ...element.recipes]);
  
          print('|');
          print(circleRecipeIds);
          print('|');
          // List&lt;String&gt; circleOnlyRecipeIds = circleRecipeIds;
          // circleRecipeIds.removeWhere((e) =&gt; userRecipesIds.contains(e));
          // print(circleOnlyRecipeIds);
        }
      });
  
      // reduce the list of recipes to a set of only circle recipes
      //TODO
  
      //------- Try with RX dart
  
      Stream&lt;RecipesState&gt; recipesStream = _recipesBloc.stream;
      Stream&lt;CirclesState&gt; circlesStream = _circlesCubit.stream;
      Rx.combineLatest2(recipesStream, circlesStream, (
        RecipesState recipesState,
        CirclesState circlesState,
      ) {
        print(&quot;This doesn't print!&quot;);
        print(recipesState);
        print(circlesState);
  
        if (recipesState is RecipesLoaded) {
          userRecipesIds = recipesState.recipes.map((e) =&gt; e.id).toList();
          print('*');
          print(userRecipesIds);
          print('*');
        }
        if (circlesState is CirclesLoaded) {
          circleRecipeIds = circlesState.circles.fold([],
              (previousValue, element) =&gt; [...previousValue, ...element.recipes]);
  
          print('|');
          print(circleRecipeIds);
          print('|');
          // List&lt;String&gt; circleOnlyRecipeIds = circleRecipeIds;
          // circleRecipeIds.removeWhere((e) =&gt; userRecipesIds.contains(e));
          // print(circleOnlyRecipeIds);
  
        }
        // fetch the set of recipes
      });
    }
  
    @override
    Future&lt;void&gt; close() {
      _recipesSubscription.cancel();
      _circlesSubscription.cancel();
      return super.close();
    }
  }
  </code></pre>
  <p>So above is my cubit - it listens to the recipesBloc and the circlesCubit. The first two expressions in the <code>getCiricleRecipes()</code> function are only there to prove that its hooked up correctly - when it runs those print statement print the ids I want it to from both the other bloc and the other cubit.</p>
  <p>I need the latest values from both though at the same time to compare them - so I thought rx.combinelatest2 would be good. I give it the stream from the bloc and the cubit. But the combiner function doesn't even run even though things seem 'wired up' correctly.</p>
  <p>Any help greatly appreciated.</p>