@@ -7,35 +7,43 @@ class NgModelOptions {
7
7
int _debounceChangeValue;
8
8
int _debounceInputValue;
9
9
10
+ async .Timer _blurTimer;
11
+ async .Timer _changeTimer;
12
+ async .Timer _inputTimer;
13
+
10
14
static const String _DEBOUNCE_DEFAULT_KEY = "default" ;
11
15
static const String _DEBOUNCE_BLUR_KEY = "blur" ;
12
16
static const String _DEBOUNCE_CHANGE_KEY = "change" ;
13
17
static const String _DEBOUNCE_INPUT_KEY = "input" ;
14
18
15
19
NgModelOptions (NodeAttrs attrs) {
16
- Map options = convert.JSON .decode (attrs["ng-model-options" ].replaceFirst ("debounce" , "'debounce'" ).replaceAll ("'" , "\" " ));
20
+ var jsonFormattedOptions = attrs["ng-model-options" ].replaceFirst ("debounce" , "'debounce'" )
21
+ .replaceAll ("'" , "\" " );
22
+ Map options = convert.JSON .decode (jsonFormattedOptions);
17
23
18
- if (options["debounce" ].containsKey (_DEBOUNCE_DEFAULT_KEY )){
19
- _debounceDefaultValue = options["debounce" ][_DEBOUNCE_DEFAULT_KEY ];
24
+ if (options["debounce" ] is int ){
25
+ _debounceDefaultValue = options["debounce" ];
26
+ }else {
27
+ if (options["debounce" ].containsKey (_DEBOUNCE_DEFAULT_KEY )){
28
+ _debounceDefaultValue = options["debounce" ][_DEBOUNCE_DEFAULT_KEY ];
29
+ }
30
+ _debounceBlurValue = options["debounce" ][_DEBOUNCE_BLUR_KEY ];
31
+ _debounceChangeValue = options["debounce" ][_DEBOUNCE_CHANGE_KEY ];
32
+ _debounceInputValue = options["debounce" ][_DEBOUNCE_INPUT_KEY ];
20
33
}
21
- _debounceBlurValue = options["debounce" ][_DEBOUNCE_BLUR_KEY ];
22
- _debounceChangeValue = options["debounce" ][_DEBOUNCE_CHANGE_KEY ];
23
- _debounceInputValue = options["debounce" ][_DEBOUNCE_INPUT_KEY ];
24
34
}
25
35
26
- async . Timer _blurTimer;
36
+
27
37
void executeBlurFunc (func ()) {
28
38
var delay = _debounceBlurValue == null ? _debounceDefaultValue : _debounceBlurValue;
29
- _blurTimer = _runFuncDebounced (delay, func,_blurTimer);
39
+ _blurTimer = _runFuncDebounced (delay, func, _blurTimer);
30
40
}
31
41
32
- async .Timer _changeTimer;
33
42
void executeChangeFunc (func ()) {
34
43
var delay = _debounceChangeValue == null ? _debounceDefaultValue : _debounceChangeValue;
35
44
_changeTimer = _runFuncDebounced (delay, func, _changeTimer);
36
45
}
37
46
38
- async .Timer _inputTimer;
39
47
void executeInputFunc (func ()) {
40
48
var delay = _debounceInputValue == null ? _debounceDefaultValue : _debounceInputValue;
41
49
_inputTimer = _runFuncDebounced (delay, func, _inputTimer);
0 commit comments