Skip to content

Switch implementation #13

@emaglio

Description

@emaglio

The aim is to have a simple API to be able to recreate a case/when block with TRB.
Here the flowchart of an operation using a Switch macro:
image

Requirements:

  • one branch step in the beginning
  • one "track" or whatever (path??) per option
  • multiple ends per "path"
  • arbitrary connections amongst the "paths" (as an additional feature)

Possible API solution:

class ChargeSwitch < Trailblazer::Operation
      class Braintree < Trailblazer::Activity::Signal; end 
      .....
      
      step Switch(condition: :set_condition) {
        option "stripe",    Trailblazer::Operation::Nested(ChargeStripe)
        option "braintree", :braintree, Output(Braintree, :success) => Track(:braintree)
        option /./,         :unsupported
      }
      
      ......
end

Here the branch where a draft implementation has been done (not the best but the tests are reusable): https://github.com/trailblazer/trailblazer-macro/tree/macro_switch

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions