Skip to content

Instantly share code, notes, and snippets.

@reharik
Last active November 13, 2015 23:36
Show Gist options
  • Select an option

  • Save reharik/b52efc0cf26b64ef4896 to your computer and use it in GitHub Desktop.

Select an option

Save reharik/b52efc0cf26b64ef4896 to your computer and use it in GitHub Desktop.
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