Skip to content

Add delay and similar utils to the Fx continuations #1277

Closed
@raulraja

Description

@raulraja

Currently using delay from the coroutines lib in a Fx continuation results in a runtime exception:

fx {
  !effect {
    otherGreetings()
    greetings()
  }
}

private suspend fun greetings() {
  delay(100)
  println("Hello!")
}

private suspend fun otherGreetings() {
  delay(200)
  println("Hi!")
}
Caused by: kotlin.UninitializedPropertyAccessException: lateinit property returnedMonad has not been initialized
        at arrow.typeclasses.MonadContinuation.getReturnedMonad(MonadContinuations.kt:49)
        at arrow.effects.typeclasses.MonadDeferCancellableContinuation.returnedMonad(MonadDeferCancellableContinuations.kt:32)
        at arrow.effects.typeclasses.Concurrent$DefaultImpls.bindingConcurrent(Concurrent.kt:710)
        at arrow.effects.extensions.IOConcurrent$DefaultImpls.bindingConcurrent(Unknown Source:8)
        at arrow.effects.extensions.io.concurrent.IOConcurrentKt$concurrent$1.bindingConcurrent(IOConcurrent.kt:443)
        at arrow.effects.typeclasses.suspended.concurrent.Fx$DefaultImpls.fx(Fx.kt:12)
        at arrow.effects.extensions.IOFx$DefaultImpls.fx(Unknown Source:8)
        at arrow.effects.extensions.io.fx.IOFxKt$fx$1.fx(IOFx.kt:49)
        at arrow.effects.extensions.io.fx.IOFxKt.fx(IOFx.kt:25)

Originally reported in gitter https://gitter.im/arrow-kt/Lobby?at=5c52d4998aa5ca5abf5f23e5

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