Reputation: 1601
I'm building a separated boxes as angular 2 components
which are uploading photos to server and then if receive success from server then there is sending a request to create an record in db. the structure is simple which is presented below. There can be n
child's and when user clicks a button to upload all I need to call upload method in every child. Normally I would use service and subscribe
method but I want to add queue to prevent overloading server. Is there any way to achieve it in this component logic?
<parent>
<child>
<child>
...
<child>
</parent>
Upvotes: 0
Views: 940
Reputation: 1894
You may think about output your data form each of your child into your parent component then you can send each data one by one if you want.
Ex :
<parent>
<child (dataToSend)="handleDatatoPush($event)"></child>
<child (dataToSend)="handleDatatoPush($event)"></child>
...
<child (dataToSend)="handleDatatoPush($event)"></child>
</parent>
parent component:
handleDatatoPush(dataReceive: any){
//your logic even if i would do something like that
this.dataToSend.push(dataReceive);
}
Then you may send your data one by one in your sendAll function.
Upvotes: 1