Optional argument, contract function
diff --git a/projects/demo/src/modules/decorators/default-prop/import/example-decorator.txt b/projects/demo/src/modules/decorators/default-prop/import/example-decorator.txt
index f93de8af8612..4565064f382a 100644
--- a/projects/demo/src/modules/decorators/default-prop/import/example-decorator.txt
+++ b/projects/demo/src/modules/decorators/default-prop/import/example-decorator.txt
@@ -1,9 +1,6 @@
@Input()
-min = 10;
-
-@Input()
-@tuiDefaultProp(
- (quantity, context) => Number.isInteger(quantity) && quantity >= context.min,
- 'Should be ingeter number more than min value'
+@tuiDefaultProp(
+ quantity => Number.isInteger(quantity) && quantity >= 5,
+ 'Should be integer number more than min value'
)
quantity = 10;
diff --git a/projects/demo/src/modules/decorators/pure/pure.template.html b/projects/demo/src/modules/decorators/pure/pure.template.html
index 447a71d52649..0c191e2ba391 100644
--- a/projects/demo/src/modules/decorators/pure/pure.template.html
+++ b/projects/demo/src/modules/decorators/pure/pure.template.html
@@ -1,23 +1,19 @@
- Decorator for memoization result of pure functions and getters
+ Decorator for memoization of pure methods and getters
-
- Warning: decorator overrides getter/setter and
- result
-
-
- Decorator can help to memoize a result of function or getter that
- can be computed once in the first call. The next calls will just use
- computed static value.
+ Decorator can help to cache result of methods or getters that can be
+ computed once in the first call. The next calls to getter will just
+ use computed static value.
+
If you use decorator with methods, it does not compute the result
- again if arguments did not change after the last call (the similar
- idea with Angular pure pipes)
+ again if arguments did not change after the last call (concept
+ similar to Angular pure pipes)
diff --git a/projects/demo/src/modules/decorators/required-setter/import/example-decorator.txt b/projects/demo/src/modules/decorators/required-setter/import/example-decorator.txt
index fe97064fb95e..cf3bd9ffc919 100644
--- a/projects/demo/src/modules/decorators/required-setter/import/example-decorator.txt
+++ b/projects/demo/src/modules/decorators/required-setter/import/example-decorator.txt
@@ -1,10 +1,7 @@
@Input()
-min = 10;
-
-@Input()
-@tuiRequiredSetter(
- (quantity, context) => Number.isInteger(quantity) && quantity >= context.min,
- 'Should be ingeter number more than min value',
+@tuiRequiredSetter(
+ quantity => Number.isInteger(quantity) && quantity >= 10,
+ 'Should be integer number more than min value',
)
set quantity(quantity: number) {
this.items = new Array(quantity).fill(Math.floor(Math.random() * Math.floor(100)));
diff --git a/projects/demo/src/modules/decorators/required-setter/required-setter-demo.component.ts b/projects/demo/src/modules/decorators/required-setter/required-setter-demo.component.ts
index a02f2217e02d..5dc7019da324 100644
--- a/projects/demo/src/modules/decorators/required-setter/required-setter-demo.component.ts
+++ b/projects/demo/src/modules/decorators/required-setter/required-setter-demo.component.ts
@@ -10,12 +10,9 @@ import {changeDetection} from '../../../change-detection-strategy';
})
export class ExampleTuiRequiredSetterDemoComponent {
@Input()
- min = 10;
-
- @Input()
- @tuiRequiredSetter(
- (quantity, context) => Number.isInteger(quantity) && quantity >= context.min,
- 'Should be ingeter number more than min value',
+ @tuiRequiredSetter(
+ quantity => Number.isInteger(quantity) && quantity >= 5,
+ 'Should be integer number more than min value',
)
set quantity(quantity: number) {
this.items = new Array(quantity).fill(
diff --git a/projects/demo/src/modules/decorators/required-setter/required-setter.component.ts b/projects/demo/src/modules/decorators/required-setter/required-setter.component.ts
index 68e174e156b9..2efbf336a2ac 100644
--- a/projects/demo/src/modules/decorators/required-setter/required-setter.component.ts
+++ b/projects/demo/src/modules/decorators/required-setter/required-setter.component.ts
@@ -10,9 +10,7 @@ import {changeDetection} from '../../../change-detection-strategy';
export class ExampleTuiRequiredSetterComponent {
exampleDecorator = exampleDecorator;
- quantity: number | undefined;
-
- min = 10;
+ quantity?: number;
setUndefined() {
this.quantity = undefined;
diff --git a/projects/demo/src/modules/decorators/required-setter/required-setter.template.html b/projects/demo/src/modules/decorators/required-setter/required-setter.template.html
index 87512d3880b8..07f29e41a204 100644
--- a/projects/demo/src/modules/decorators/required-setter/required-setter.template.html
+++ b/projects/demo/src/modules/decorators/required-setter/required-setter.template.html
@@ -1,19 +1,22 @@
- Decorator setter @Input
-
+ Decorator setter @Input
+
+
+ Decorator stops undefined
values if they were passed
+ into setter input. If it gets undefined
, setter will
+ not be called and it will show an error message about the problem in
+ console in dev mode.
+
+
-
See console
+
See console. Min value is 5
quantity
-
- min
-