Skip to content

Would syntactic sugar for ifM, unlessA, and whenA be worth adding? #192

@morgen-peschke

Description

@morgen-peschke

For boolVariation keys, it seems common to end up passing this directly to ifM, whenA, or unlessA, is this something that would be worth adding helpers to make this a bit smoother?

Current:

launchDarklyMtlClient
  .boolVariation("some-feature-flag", false)
  .flatMap { tryV2 =>
    if (tryV2) algebra.foo else algebraV2.bar
  }

launchDarklyMtlClient
  .boolVariation("some-feature-flag", false)
  .ifM(
    ifTrue = algebra.foo,
    ifFalse = algebraV2.bar
  )

launchDarklyMtlClient
  .variation(SomeFeatureFlag)
  .flatMap { extraLogging =>
    logger.info("Extra logging stuff").whenA(extraLogging)
  }

Proposed:

launchDarklyMtlClient
  .ifV("some-feature-flag", false)(
    ifTrue = algebra.foo,
    ifFalse = algebraV2.bar
  )

launchDarklyMtlClient
  .whenV(SomeFeatureFlag) {
    logger.info("Extra logging stuff")
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions