"Can't resolve all parameters” in Ionic

I have this app.module.ts code:


    import { BrowserModule } from '@angular/platform-browser';
    import { ErrorHandler, NgModule } from '@angular/core';
    import { IonicApp, IonicErrorHandler, IonicModule, ToastController } from 'ionic-angular';
    import { IonicStorageModule } from '@ionic/storage';
    
    import { MyApp } from './app.component';
    import { HomePage } from '../pages/home/home';
    import { ListPage } from '../pages/list/list';
    import {EmailComposer} from '@ionic-native/email-composer';
    
    import { StatusBar } from '@ionic-native/status-bar';
    import { SplashScreen } from '@ionic-native/splash-screen';
    import { AuthService } from '../providers/auth-service/auth-service';
    import { RegisterPage } from '../pages/register/register';
    import { LoginPage } from '../pages/login/login';
    import { MainPage } from '../pages/main/main';
    import { Example_1Page } from '../pages/example-1/example-1';
    import { File } from '@ionic-native/file';
    
    import { SignaturePadModule } from 'angular2-signaturepad';
    import { Diagnostic } from '@ionic-native/diagnostic';
    import {Subscription} from 'rxjs'
    
    @NgModule({
      declarations: [
        MyApp,
        ListPage,
        HomePage,
        MainPage,
        LoginPage,
        RegisterPage,
        Example_1Page
         
      ],
      imports: [
        BrowserModule,
        SignaturePadModule,
        IonicModule.forRoot(MyApp),
        IonicStorageModule.forRoot()
      ],
      bootstrap: [IonicApp],
      entryComponents: [
        MyApp,
       
      ],
      providers: [
        Subscription,
        SplashScreen,
        {provide: ErrorHandler, useClass: IonicErrorHandler},
        AuthService,
        
        
      ]
    })
    export class AppModule {}

I need to add Subscription as a provider, as I do above. But when I do, I get the following error:

Error: Can’t resolve all parameters for Subscription: (?).

What is the problem? None of the other providers give me this issue!

EDIT: Why does it say it needs parameters. I tried adding Subscription as a provider for the page but it still didn’t work. This as never happened to me before!

No you don’t. That makes no sense.

When I don’t put it as a provider, it says I can;t use it because it has no provider for it!

None of that makes any sense. Post the relevant code and the exact error message.

Hello,
You would be use Subscription class as returning data type from Observables. For Example:

    import   Rx, { Subscription } from 'rxjs/Rx'; 
    let source  = Rx.Observable.create( (observer:Subscription) => {
       ... 
    });
    source.subscribe( (data:Subscription) => {
       ... 
    }); 

How can I run an action every seconding using the method above?

Hello,

maybe you are looking for interval of rxjs. see here https://www.learnrxjs.io/operators/creation/interval.html

Best regards, anna-liebt

That is a horrible idea. Users need to be in control of their battery life. Push notifications exist for a reason.