Last active
October 8, 2015 19:03
-
-
Save evanshortiss/7d601040606732747102 to your computer and use it in GitHub Desktop.
async.filter - An Example of an Asynchronous filter
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
// Assumes you've included the async library | |
var async = window.async | |
, userInput = $('input').val() // <== just an example, could use ng-model too in angular | |
, originalList = getTheHugeDataSetFromSomewhere() | |
, $scope.items = []; | |
async.filter(originalList, function (item, cb) { | |
// Check does the user input exist in the name | |
cb(item.name.indexOf(userInput) !== -1); | |
}, function (filteredItems) { | |
$scope.items = filteredItems; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment