scalafrontendscala.jsdiode

Diode. Send more than 1 action in circuit


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


Solution

  • 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 => ???
        }
    }