Last active
November 13, 2015 23:36
-
-
Save reharik/b52efc0cf26b64ef4896 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| function(handlers) { | |
| var log = function(x){ console.log(x); return x; }; | |
| var Left =_fantasy.Either.Left; | |
| var Right =_fantasy.Either.Right; | |
| var getHandlers = R.isEmpty(handlers) ? Left('Dispatcher requires at least one handler') : Right(handlers); | |
| //matchHandler:: handler -> bool | |
| var matchHandler2 = x=> true; | |
| //matchHandlers:: [handler] -> [handler] | |
| var matchHandlers = handlers => handlers.filter(matchHandler2); | |
| //serveEventToHandlers:: [handers] -> json -> right(result) | left(error) | |
| //var getMatchingHandler= R.compose(R.map(matchHandlers), getHandlers); | |
| var getMatchingHandler= getHandlers.map(matchHandlers); | |
| console.log("wtfxxxxxxxxxxxxxx") | |
| return { | |
| getHandlers, | |
| matchHandlers, | |
| getMatchingHandler, | |
| serveEventToHandlers | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment