@dikman/ngx-tools
v0.1.1
Published
Usefull decorators for Angular project.
Downloads
7
Maintainers
Readme
NgxTools
Usefull decorators and helpers for Angular project.
Install
npm install --save @dikman/ngx-tools
Usage
Decorators are exported as start case.
import { Debounce } from '@dikman/ngx-tools';
Decorators
These decorators are included in the package.
Debounce
Singleton
Debounce
Decorator that creates a debounced function that delays invoking function until after wait milliseconds have elapsed since the last time the debounced function was invoked.
import { Debounce } from '@dikman/ngx-tools';
export class ExampleComponent {
@Debounce() protected searchSomeData(): void {
...
}
}
Singleton
Decorator that restricts the instantiation of a class to one "single" instance. This is useful when exactly one object is needed to coordinate actions across the system.
import { Singleton } from '@dikman/ngx-tools';
@Injectable({
providedIn: 'root'
})
@Singleton()
export class ExampleService {
constructor() {
...
}
}
Random Helper
Collection of functions for generating a random value of primitive types.
number(min, max)
Generates a random integer from a given range (a result can include at both the minimum and the maximum of the range).
import { Random } from '@dikman/ngx-tools';
console.log(Random.number(5, 25));
color()
Generates a random color as a string starts with the '#' char.
import { Random } from '@dikman/ngx-tools';
console.log(Random.color());
string([length])
Generates a random string of a given length.
import { Random } from '@dikman/ngx-tools';
console.log(Random.string(32));