Cancel background process when leaving a component to another?











up vote
10
down vote

favorite
1












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.



enter image description here



  <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.










share|improve this question
























  • 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 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










  • @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















up vote
10
down vote

favorite
1












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.



enter image description here



  <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.










share|improve this question
























  • 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 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










  • @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













up vote
10
down vote

favorite
1









up vote
10
down vote

favorite
1






1





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.



enter image description here



  <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.










share|improve this question















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.



enter image description here



  <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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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 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










  • @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










  • 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












  • @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

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















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






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Guess what letter conforming each word

Port of Spain

Run scheduled task as local user group (not BUILTIN)