One of my components, called First
, is responsible for creating a new instance of a Worker
class.
During the creation process of this class, I intend to pass the Read
method as a callback method. Once this class completes its task, it will then invoke this method.
I have previously implemented this functionality in vanilla JavaScript. My question is, can I achieve the same in Angular 6?
@Component({
selector: 'app-campaign-settings',
templateUrl: './campaign-settings.component.html',
styleUrls: ['./campaign-settings.component.css']
})
export class First implements OnInit {
worker: Worker = null;
Work() {
worker=new Worker(this.Read);
worker.Run();
}
Read() {
// Perform necessary operations
}
}
export class Worker implements OnInit {
callback: any;
constructor(i_callback: any) {
// Initialize
}
Run() {
callback();
}
}