Reactivecocoa: Share 1 Action for different "loading" signals

Created on 25 Sep 2015  路  1Comment  路  Source: ReactiveCocoa/ReactiveCocoa

I have a fetchStatusesAction that triggers an API request. The action has [String]? as its input, which is either nil to fetch all, or an array of string IDs to fetch a subset of the data.

I'm trying to use the action's executing producer so I can display a loading state for each of the individual status cells. When all statuses are fetched, every cell should show a spinner. When just 1 status is fetched (via fetchStatusesAction.apply(["some-id"]).start()), only its cell should show the spinner.

I _think_ what i'm struggling with is that, when the action is executing, there is no way to find out what input it started with and therefore no way to filter the "loading" signal to just the relevant cell.

Is this possible?

question

Most helpful comment

Instead of passing a [String]? use something like this:

enum Statuses {
  case All
  case SubSet([String])
}

You shouldn't rely on nullability to represent your intentions. Make the most of Swift's features! 馃

>All comments

Instead of passing a [String]? use something like this:

enum Statuses {
  case All
  case SubSet([String])
}

You shouldn't rely on nullability to represent your intentions. Make the most of Swift's features! 馃

Was this page helpful?
0 / 5 - 0 ratings