-
Notifications
You must be signed in to change notification settings - Fork 331
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
32 additions
and
14 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/** | ||
* Bunch of useful filters for angularJS(with no external dependencies!) | ||
* @version v0.5.0 - 2014-11-12 * @link https://github.com/a8m/angular-filter | ||
* @version v0.5.1 - 2014-11-12 * @link https://github.com/a8m/angular-filter | ||
* @author Ariel Mashraki <[email protected]> | ||
* @license MIT License, http://www.opensource.org/licenses/MIT | ||
*/ | ||
|
@@ -853,11 +853,6 @@ angular.module('a8m.group-by', [ 'a8m.filter-watcher' ]) | |
|
||
var getterFn = $parse(property); | ||
|
||
// If it's called outside the DOM | ||
if(!isScope(this)) { | ||
return _groupBy(collection, getterFn); | ||
} | ||
// Return the memoized|| memozie the result | ||
return filterWatcher.isMemoized('groupBy', arguments) || | ||
filterWatcher.memoize('groupBy', arguments, this, | ||
_groupBy(collection, getterFn)); | ||
|
@@ -1975,7 +1970,7 @@ angular.module('a8m.wrap', []) | |
angular.module('a8m.filter-watcher', []) | ||
.provider('filterWatcher', function() { | ||
|
||
this.$get = [function() { | ||
this.$get = ['$window', '$rootScope', function($window, $rootScope) { | ||
|
||
/** | ||
* Cache storing | ||
|
@@ -1991,6 +1986,12 @@ angular.module('a8m.filter-watcher', []) | |
*/ | ||
var $$listeners = {}; | ||
|
||
/** | ||
* $timeout without triggering the digest cycle | ||
* @type {function} | ||
*/ | ||
var $$timeout = $window.setTimeout; | ||
|
||
/** | ||
* @description | ||
* get `HashKey` string based on the given arguments. | ||
|
@@ -2019,6 +2020,18 @@ angular.module('a8m.filter-watcher', []) | |
delete $$listeners[id]; | ||
} | ||
|
||
/** | ||
* @description | ||
* for angular version that greater than v.1.3.0 | ||
* if clear cache when the digest cycle end. | ||
*/ | ||
function cleanStateless() { | ||
$$timeout(function() { | ||
if(!$rootScope.$$phase) | ||
$$cache = {}; | ||
}); | ||
} | ||
|
||
/** | ||
* @description | ||
* Store hashKeys in $$listeners container | ||
|
@@ -2062,8 +2075,13 @@ angular.module('a8m.filter-watcher', []) | |
var hashKey = getHashKey(filterName, args); | ||
//store result in `$$cache` container | ||
$$cache[hashKey] = result; | ||
//add `$destroy` listener | ||
addListener(scope, hashKey); | ||
// for angular versions that less than 1.3 | ||
// add to `$destroy` listener, a cleaner callback | ||
if(isScope(scope)) { | ||
addListener(scope, hashKey); | ||
} else { | ||
cleanStateless(); | ||
} | ||
return result; | ||
} | ||
|
||
|
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
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