Within my project, I have established an interface in the following manner:
interface IExport {
export(): Observable<ArrayBuffer>;
}
An assortment of services are designed to adhere to this interface. Take, for instance:
@Injectable({ providedIn: 'root' })
export class BookService implements IExport {
export() { // }
}
@Injectable({ providedIn: 'root' })
export class CompanyService implements IExport {
export() { // }
}
@Injectable({ providedIn: 'root' })
export class DocumentService implements IExport {
export() { // }
}
Given that I do not make any explicit reference to this interface from a component, is it truly beneficial or necessary to maintain the existence of IExport? The current utilization is demonstrated as follows:
@Component({
selector: 'app-book-component',
templateUrl: './book.component.html'
})
export class BookComponent {
constructor(private service: BookService)
exportBook(){
service.export().subscribe();
}
}
As illustrated, there is no explicit specification of the service within the component as an IExportService. In light of this, should I retain, discard, or only apply the interface when essential?