Skip to content

Instantly share code, notes, and snippets.

@wildermuthn
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wildermuthn/d18a8bbe1cc27ff6d51b to your computer and use it in GitHub Desktop.
Save wildermuthn/d18a8bbe1cc27ff6d51b to your computer and use it in GitHub Desktop.
New Ramda Switch
<input ng-model="filter.search" type="text" />
<select ng-model="filter.category" ng-options="c for c in categories" />
R.fnSwitch = function(fnList) {
return R.mapObjIndexed((val, key) => fnList[key](val));
};
var fnList = {
'search': function(search) {
// Filter by search string
},
'category': function(category) {
// Filter by category
},
}
var mySwitch = R.fnSwitch(fnList);
$scope.$watchCollection('filter', function(filter) {
mySwitch(filter);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment