tech-advantage / ngx-icon-picker

An Icon Picker Directive/Component for Angular 13+ which manages Font Awesome, Bootstrap Glyphicon, Font Awesome5 and Material.
MIT License
24 stars 33 forks source link

onInit emits iconPickerSelect event #64

Open janschab opened 1 year ago

janschab commented 1 year ago

hello, onInit hook calls this.iconPickerSelect.emit(this.iconPicker);. Does it serve any purpose? Imo event should only be sent when there is a icon change.

ngOnInit() {
    this.iconPicker = this.iconPicker || this.ipFallbackIcon || 'fa fa-user-plus';
    this.iconPickerSelect.emit(this.iconPicker);
}

I would be grateful if I could contribute and do PR that will make emitting event optional in onInit.

@Input() emitEventOnInit: boolean = true;

ngOnInit() {
    this.iconPicker = this.iconPicker || this.ipFallbackIcon || 'fa fa-user-plus';

    if (this.emitEventOnInit) {
        this.iconPickerSelect.emit(this.iconPicker);
    }
}