Cancel background process when leaving a component to another?
up vote
10
down vote
favorite
I am using this libray:
https://github.com/VadimDez/ng2-pdf-viewer
I have created a repository with an example of my problem.
https://github.com/YeisonVelez11/pdf
I am generating a pdf, and this works well. but if the pdf has not finished loading and I navigate to another component, I get an error.
Basically when I go back to a preview, I get a problem because the pdf that is being loaded can not be canceled. I do not know what trick I can do to get out of the document view at any time.
<pdf-viewer [src]="archivo_adjunto"
*ngIf="archivo_adjunto"
[render-text]="false"
[original-size]="true"
[page]="1"
[autoresize]="true"
[show-all]="true"
style="display: block;"
(page-rendered)="pageRendered($event)"
></pdf-viewer>
ionViewDidLoad() {
this.archivo_adjunto="./assets/documents/Resumen Ejecutivo Autoevaluacion.pdf"
}
This is done in Ionic, but the functionality is in Angular.
angular ionic-framework
|
show 1 more comment
up vote
10
down vote
favorite
I am using this libray:
https://github.com/VadimDez/ng2-pdf-viewer
I have created a repository with an example of my problem.
https://github.com/YeisonVelez11/pdf
I am generating a pdf, and this works well. but if the pdf has not finished loading and I navigate to another component, I get an error.
Basically when I go back to a preview, I get a problem because the pdf that is being loaded can not be canceled. I do not know what trick I can do to get out of the document view at any time.
<pdf-viewer [src]="archivo_adjunto"
*ngIf="archivo_adjunto"
[render-text]="false"
[original-size]="true"
[page]="1"
[autoresize]="true"
[show-all]="true"
style="display: block;"
(page-rendered)="pageRendered($event)"
></pdf-viewer>
ionViewDidLoad() {
this.archivo_adjunto="./assets/documents/Resumen Ejecutivo Autoevaluacion.pdf"
}
This is done in Ionic, but the functionality is in Angular.
angular ionic-framework
If you can stop loading of PDF manually just add that code inngOnDestroy()
. It will get called when you change route and stop your process of loading PDF.
– Vishw Patel
Nov 1 at 6:36
how can import that in ionic?
– yavg
Nov 1 at 17:51
That seems like a bug in the library but if the(page-rendered)
event is triggered when the pdf is ready, you could prevent the user to close the page using theionViewCanLeave
lifecycle event. This is not a fix for the error, but a way to prevent it until the owner of the library fixes that issue. If you think this may help, please let me know and I'll write an answer with more details.
– sebaferreras
Nov 3 at 10:04
@sebaferreras you pretend that until the pdf has been rendered, the user can not leave the current view? I would like to see your solution, it is not an elegant solution but maybe it could work. I would like you to please show me how to do it, and if you have good behavior, the best answer will be yours.
– yavg
Nov 4 at 3:31
@yavg hi.. you got a solution for this ? else i can spend some time one the repo you shared.. please let me know ASAP.
– Rameez Rami
Nov 9 at 11:00
|
show 1 more comment
up vote
10
down vote
favorite
up vote
10
down vote
favorite
I am using this libray:
https://github.com/VadimDez/ng2-pdf-viewer
I have created a repository with an example of my problem.
https://github.com/YeisonVelez11/pdf
I am generating a pdf, and this works well. but if the pdf has not finished loading and I navigate to another component, I get an error.
Basically when I go back to a preview, I get a problem because the pdf that is being loaded can not be canceled. I do not know what trick I can do to get out of the document view at any time.
<pdf-viewer [src]="archivo_adjunto"
*ngIf="archivo_adjunto"
[render-text]="false"
[original-size]="true"
[page]="1"
[autoresize]="true"
[show-all]="true"
style="display: block;"
(page-rendered)="pageRendered($event)"
></pdf-viewer>
ionViewDidLoad() {
this.archivo_adjunto="./assets/documents/Resumen Ejecutivo Autoevaluacion.pdf"
}
This is done in Ionic, but the functionality is in Angular.
angular ionic-framework
I am using this libray:
https://github.com/VadimDez/ng2-pdf-viewer
I have created a repository with an example of my problem.
https://github.com/YeisonVelez11/pdf
I am generating a pdf, and this works well. but if the pdf has not finished loading and I navigate to another component, I get an error.
Basically when I go back to a preview, I get a problem because the pdf that is being loaded can not be canceled. I do not know what trick I can do to get out of the document view at any time.
<pdf-viewer [src]="archivo_adjunto"
*ngIf="archivo_adjunto"
[render-text]="false"
[original-size]="true"
[page]="1"
[autoresize]="true"
[show-all]="true"
style="display: block;"
(page-rendered)="pageRendered($event)"
></pdf-viewer>
ionViewDidLoad() {
this.archivo_adjunto="./assets/documents/Resumen Ejecutivo Autoevaluacion.pdf"
}
This is done in Ionic, but the functionality is in Angular.
angular ionic-framework
angular ionic-framework
edited Nov 10 at 14:33
halfer
14.2k757106
14.2k757106
asked Nov 1 at 5:08
yavg
682825
682825
If you can stop loading of PDF manually just add that code inngOnDestroy()
. It will get called when you change route and stop your process of loading PDF.
– Vishw Patel
Nov 1 at 6:36
how can import that in ionic?
– yavg
Nov 1 at 17:51
That seems like a bug in the library but if the(page-rendered)
event is triggered when the pdf is ready, you could prevent the user to close the page using theionViewCanLeave
lifecycle event. This is not a fix for the error, but a way to prevent it until the owner of the library fixes that issue. If you think this may help, please let me know and I'll write an answer with more details.
– sebaferreras
Nov 3 at 10:04
@sebaferreras you pretend that until the pdf has been rendered, the user can not leave the current view? I would like to see your solution, it is not an elegant solution but maybe it could work. I would like you to please show me how to do it, and if you have good behavior, the best answer will be yours.
– yavg
Nov 4 at 3:31
@yavg hi.. you got a solution for this ? else i can spend some time one the repo you shared.. please let me know ASAP.
– Rameez Rami
Nov 9 at 11:00
|
show 1 more comment
If you can stop loading of PDF manually just add that code inngOnDestroy()
. It will get called when you change route and stop your process of loading PDF.
– Vishw Patel
Nov 1 at 6:36
how can import that in ionic?
– yavg
Nov 1 at 17:51
That seems like a bug in the library but if the(page-rendered)
event is triggered when the pdf is ready, you could prevent the user to close the page using theionViewCanLeave
lifecycle event. This is not a fix for the error, but a way to prevent it until the owner of the library fixes that issue. If you think this may help, please let me know and I'll write an answer with more details.
– sebaferreras
Nov 3 at 10:04
@sebaferreras you pretend that until the pdf has been rendered, the user can not leave the current view? I would like to see your solution, it is not an elegant solution but maybe it could work. I would like you to please show me how to do it, and if you have good behavior, the best answer will be yours.
– yavg
Nov 4 at 3:31
@yavg hi.. you got a solution for this ? else i can spend some time one the repo you shared.. please let me know ASAP.
– Rameez Rami
Nov 9 at 11:00
If you can stop loading of PDF manually just add that code in
ngOnDestroy()
. It will get called when you change route and stop your process of loading PDF.– Vishw Patel
Nov 1 at 6:36
If you can stop loading of PDF manually just add that code in
ngOnDestroy()
. It will get called when you change route and stop your process of loading PDF.– Vishw Patel
Nov 1 at 6:36
how can import that in ionic?
– yavg
Nov 1 at 17:51
how can import that in ionic?
– yavg
Nov 1 at 17:51
That seems like a bug in the library but if the
(page-rendered)
event is triggered when the pdf is ready, you could prevent the user to close the page using the ionViewCanLeave
lifecycle event. This is not a fix for the error, but a way to prevent it until the owner of the library fixes that issue. If you think this may help, please let me know and I'll write an answer with more details.– sebaferreras
Nov 3 at 10:04
That seems like a bug in the library but if the
(page-rendered)
event is triggered when the pdf is ready, you could prevent the user to close the page using the ionViewCanLeave
lifecycle event. This is not a fix for the error, but a way to prevent it until the owner of the library fixes that issue. If you think this may help, please let me know and I'll write an answer with more details.– sebaferreras
Nov 3 at 10:04
@sebaferreras you pretend that until the pdf has been rendered, the user can not leave the current view? I would like to see your solution, it is not an elegant solution but maybe it could work. I would like you to please show me how to do it, and if you have good behavior, the best answer will be yours.
– yavg
Nov 4 at 3:31
@sebaferreras you pretend that until the pdf has been rendered, the user can not leave the current view? I would like to see your solution, it is not an elegant solution but maybe it could work. I would like you to please show me how to do it, and if you have good behavior, the best answer will be yours.
– yavg
Nov 4 at 3:31
@yavg hi.. you got a solution for this ? else i can spend some time one the repo you shared.. please let me know ASAP.
– Rameez Rami
Nov 9 at 11:00
@yavg hi.. you got a solution for this ? else i can spend some time one the repo you shared.. please let me know ASAP.
– Rameez Rami
Nov 9 at 11:00
|
show 1 more comment
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53095487%2fcancel-background-process-when-leaving-a-component-to-another%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
If you can stop loading of PDF manually just add that code in
ngOnDestroy()
. It will get called when you change route and stop your process of loading PDF.– Vishw Patel
Nov 1 at 6:36
how can import that in ionic?
– yavg
Nov 1 at 17:51
That seems like a bug in the library but if the
(page-rendered)
event is triggered when the pdf is ready, you could prevent the user to close the page using theionViewCanLeave
lifecycle event. This is not a fix for the error, but a way to prevent it until the owner of the library fixes that issue. If you think this may help, please let me know and I'll write an answer with more details.– sebaferreras
Nov 3 at 10:04
@sebaferreras you pretend that until the pdf has been rendered, the user can not leave the current view? I would like to see your solution, it is not an elegant solution but maybe it could work. I would like you to please show me how to do it, and if you have good behavior, the best answer will be yours.
– yavg
Nov 4 at 3:31
@yavg hi.. you got a solution for this ? else i can spend some time one the repo you shared.. please let me know ASAP.
– Rameez Rami
Nov 9 at 11:00