Last active
December 10, 2015 02:19
-
-
Save negator/4366999 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*Enumeratee to manage writing to the file writer. Mapping any errors to Left*/ | |
type ErrorOrActivity = Either[Error,Activity] | |
def fileWriting: Enumeratee[Activity, ErrorOrActivity] = { | |
/* writeToFile returns a Promise, but the Enumeratee type constraint | |
* does not expect a Promise. flatMap will return an | |
* Enumeratee[Activity,ErrorOrActivity] given a function from Activity | |
* to Promise[ErrorOrActivity]. | |
*/ | |
KloutEnumeratee.flatMap[ErrorOrActivity] { activity=> | |
writeToFile(activity.json).map{ | |
case e @ Failure(_) => Left(e) | |
case _ => Right(activity) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment