Base solution for your next web application
Open Closed

How to Configure Angular Component GetAll() Auto-Refresh #10266


User avatar
0
SelfSwapAdmin created

Product Version: 10.2.0 Product Type: Angular 10.NET Core 5

We need to have the GetAll() method in one of our custom components initialized from the "Load Entity from Database" code-gen automatically refresh using a configurable interval. What is the best way to go about this? Is there an example somewhere we can look at? Thank you!


5 Answer(s)
  • User Avatar
    0
    musa.demir created

    Hi @SelfSwapAdmin Does using setInterval meet your project's needs?

    ngOnInit(): void {
        this.setAutoRefreshTimer();
    }
    
    private setAutoRefreshTimer(): void {
        let getAllInterval = abp.setting.getInt("XXXComponent.GetAllInterval");
        setInterval(this.getAll, getAllInterval);
    }
    
  • User Avatar
    0
    SelfSwapAdmin created

    I oversimplified a bit. Actually what is getting called is:

    getComponentName(event?: LazyLoadEvent) {
        if (this.primengTableHelper.shouldResetPaging(event)) {
            this.paginator.changePage(0);
            return;
        }
    
        this.primengTableHelper.showLoadingIndicator();
    
        this._ssFolioServiceProxy
            .getAll(
                this.filterText,
                ..............
                ..............
    

    So GetAll is not being called directly is unresolved in setInterval(this.getAll, getAllInterval).

    So in this case how SetInterval be used?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Could you try using setInterval as below;

    setInterval(() => {
        this.getAll(); 
      }, getAllInterval);
    
  • User Avatar
    0
    SelfSwapAdmin created

    Error TS2339 (TS) Property 'getAll' does not exist on type 'XXXXXComponent'.

  • User Avatar
    0
    musa.demir created

    Hi @SelfSwapAdmin Check: https://www.w3schools.com/jsref/met_win_setinterval.asp

    setInterval(() => {
        //do whatever you want
      }, getAllInterval);