1

Colleagues, I cant make diode, to send itself more than one action from another action. here the example from App circuit:

val handler = new ActionHandler(myZoomedState) {
    override def handle = {
      case action => effectOnly(Effect(someFuture map {_ =>
        someAction  //This action doesn't perform 
        someOtherAction  //This one does
      }))

      case someAction => ???
      case someOtherAction => ???
    }
}

How can chain I actions? Something like >> whith callbacks:
someCallback >> someOtherCallback

Seth Tisue
  • 29,985
  • 11
  • 82
  • 149
Oleg
  • 899
  • 1
  • 8
  • 22

2 Answers2

0

Oleg, your questions is quite not clear. If your handlers of someAction and someOtherAction are actually effect-only as implementation of your case action suggests, you can move them into a named methods and combine them using << or >> or +. If this is not what you want, you should elaborate your problem in more details.

SergGr
  • 23,570
  • 2
  • 30
  • 51
  • They are not effects, they are actions. My solution is to create another action, combining this actions. – Oleg Feb 13 '18 at 06:22
  • @Oleg, you can freely combine effects exactly because they are just effects. For state-changing actions you should provide more details on what exactly those actions do and what combined semantics you expect to get. I don't think one can answer your question in its current generic form. I suspect that the solution you provided in your answer will not work correctly in all cases especially since you use potentially concurrent `+`. – SergGr Feb 13 '18 at 13:20
  • Sure, but I can't combine effects inside another effect. So, in my question, I can't just put `someAction` and `someOtherAction` into `Effect.action()`. – Oleg Feb 13 '18 at 14:11
  • `someFuture` is the rest request to delete item. If it was succeed, I want to perform 2 actions. First one is to update my state by `updated(value.copy( ... ))`. Second one - to recalculate my `Pot` data by sending another rest request. – Oleg Feb 13 '18 at 14:19
0

Solution is to create another action, combining this two actions. And I still can handle Future error. Looks like this:

case object DoSmthStuff
...

val handler = new ActionHandler(myZoomedState) {
    override def handle = {
      case action => effectOnly(Effect(
          someFuture map { _ => DoSmthStuff } recover { ... }
      ))

      case DoSmthStuff = effectOnly(
          Effect.action(someAction) >> Effect.action(someOtherAction)
      )

      case someAction => ???
      case someOtherAction => ???
    }
}
Oleg
  • 899
  • 1
  • 8
  • 22