First of all: Is it possible? I have a vague memory about this being possible but I cannot seem to formulate my question well enough for google / stack to give me an idea of what to do.
Given this code (transform function within a custom pipe -Angular 2-):
transform(statuses: Status[], test: string): Status[] {
return statuses.filter(status => status.Id === 1);
//Code to be executed after return has happened
this.updatePager.emit();
}
How do I get the code this.updatePager.emit();to happen right after my return statement.
Kind regards everyone. Tips on how to formulate this question so I can search further are always welcome!
This should work.
transform(statuses: Status[], test: string): Status[] {
setTimeout(function(){ this.updatePager.emit(); }, 1000); //Adjust time here.
return statuses.filter(status => status.Id === 1);
}
This might work for you, execute code in the next application tick with setTimeout 0.
transform(statuses: Status[], test: string): Status[] {
//Code to be executed in the next tick
setTimeout( ()=> this.updatePager.emit(), 0 );
return statuses.filter(status => status.Id === 1);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With