Save 37% off PRO during our Black Friday Sale! »

Hello Workflow

82ee6bce819efe5b9cc6c51dea03e8da?s=47 rjrjr
June 20, 2019

Hello Workflow

82ee6bce819efe5b9cc6c51dea03e8da?s=128

rjrjr

June 20, 2019
Tweet

Transcript

  1. Ray Ryan Zach Klippenstein Hello Square Workflow

  2. Nav logic sprawl Tragedy of convenient presenters

  3. CartScreen ChargeScreen TipScreen SignatureScreen ReceiptScreen

  4. class ChargeScreen { fun onCardSwiped(card: Card) { doStuffWithCard(card) if (tippingEnabled)

    goTo(TipScreen) else if (signatureRequired) goTo(SignatureScreen) else if (!skipReceipts) goTo(ReceiptScreen) else popTo(CartScreen) } } class TipScreen { fun onTip(tip: Money) { doStuffWithTip(tip) if (signatureRequired) goTo(SignatureScreen) else if (!skipReceipts) goTo(ReceiptScreen) else popTo(CartScreen) } }
  5. class ChargeScreen { fun onCardSwiped(card: Card) { doStuffWithCard(card) if (tippingEnabled)

    goTo(TipScreen) else if (signatureRequired) goTo(SignatureScreen) else if (!skipReceipts) goTo(ReceiptScreen) else popTo(CartScreen) } } class TipScreen { fun onTip(tip: Money) { doStuffWithTip(tip) if (signatureRequired) goTo(SignatureScreen) else if (!skipReceipts) goTo(ReceiptScreen) else popTo(CartScreen) } }
  6. CartScreen ChargeScreen TipScreen SignatureScreen ReceiptScreen

  7. class CheckoutWorkflow { } CartScreen ChargeScreen TipScreen SignatureScreen ReceiptScreen onCard

    / tipping onCard onTip onCard / skipSig onTip / skipSig onSig onSig / skipReceipt onReceipt
  8. Those who do not know React are condemned to reinvent

    it poorly.
  9. Workflow moving parts

  10. Workflow

  11. class NewGameScreen( val onStart: (String, String) -> Unit ) Rendering

    Workflow
  12. class NewGameScreen( val onStart: (String, String) -> Unit ) class

    NewGameRunner( view: View ) : LayoutRunner<NewGameScreen> { val player1 = view.findById<TextView>() // etc. fun showRendering(r: NewGameScreen) { playButton.setOnClickHandler { r.onStart(player1.text, player2.text) } } } LayoutRunner Workflow Rendering
  13. class NewGameScreen( val onStart: (String, String) -> Unit ) class

    NewGameRunner( view: View ) : LayoutRunner<NewGameScreen> { val player1 = view.findById<TextView>() // etc. fun showRendering(r: NewGameScreen) { playButton.setOnClickHandler { r.onStart(player1.text, player2.text) } } } LayoutRunner Workflow Rendering
  14. Let’s code! https://github.com/square/workflow/tree/zachklipp+ray/todo-android-livecode

  15. square.com