Skip to content
This repository has been archived by the owner on Feb 13, 2020. It is now read-only.

switchOnError operator #22

Open
jcornaz opened this issue May 12, 2018 · 0 comments
Open

switchOnError operator #22

jcornaz opened this issue May 12, 2018 · 0 comments
Labels
feature Add a new feature need-usecase This lacks of use-case for now. It has to be motivated by a concrete need before being implemented.

Comments

@jcornaz
Copy link
Owner

jcornaz commented May 12, 2018

Possible implementation:

fun <E> switchOnError(logError: (Throwable) -> Unit = {}, openChannel: () -> ReceiveChannel<E>): ReceiveChannel<E> = produce(Unconfined) {
  while(isActive) {
	try {
		openChannel().consumeEach { send(it) }
	} catch(t: Throwable) {
		logError(t)
	}
  }
}
@jcornaz jcornaz added the feature Add a new feature label May 12, 2018
@jcornaz jcornaz added the need-usecase This lacks of use-case for now. It has to be motivated by a concrete need before being implemented. label Jun 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature Add a new feature need-usecase This lacks of use-case for now. It has to be motivated by a concrete need before being implemented.
Projects
None yet
Development

No branches or pull requests

1 participant