|
|
@ -8,6 +8,7 @@ You have to provide the `SubscriptionService` at component or directive level, b |
|
|
|
|
|
|
|
|
```js |
|
|
```js |
|
|
import { SubscriptionService } from '@abp/ng.core'; |
|
|
import { SubscriptionService } from '@abp/ng.core'; |
|
|
|
|
|
import { inject } from '@angular/core'; |
|
|
|
|
|
|
|
|
@Component({ |
|
|
@Component({ |
|
|
/* class metadata here */ |
|
|
/* class metadata here */ |
|
|
@ -16,7 +17,9 @@ import { SubscriptionService } from '@abp/ng.core'; |
|
|
class DemoComponent { |
|
|
class DemoComponent { |
|
|
count$ = interval(1000); |
|
|
count$ = interval(1000); |
|
|
|
|
|
|
|
|
constructor(private subscription: SubscriptionService) { |
|
|
private subscription = inject(SubscriptionService); |
|
|
|
|
|
|
|
|
|
|
|
constructor() { |
|
|
this.subscription.addOne(this.count$, console.log); |
|
|
this.subscription.addOne(this.count$, console.log); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -38,7 +41,7 @@ You can pass a `next` function and an `error` function. |
|
|
providers: [SubscriptionService], |
|
|
providers: [SubscriptionService], |
|
|
}) |
|
|
}) |
|
|
class DemoComponent implements OnInit { |
|
|
class DemoComponent implements OnInit { |
|
|
constructor(private subscription: SubscriptionService) {} |
|
|
private subscription = inject(SubscriptionService); |
|
|
|
|
|
|
|
|
ngOnInit() { |
|
|
ngOnInit() { |
|
|
const source$ = interval(1000); |
|
|
const source$ = interval(1000); |
|
|
@ -61,7 +64,7 @@ Or, you can pass an observer. |
|
|
providers: [SubscriptionService], |
|
|
providers: [SubscriptionService], |
|
|
}) |
|
|
}) |
|
|
class DemoComponent implements OnInit { |
|
|
class DemoComponent implements OnInit { |
|
|
constructor(private subscription: SubscriptionService) {} |
|
|
private subscription = inject(SubscriptionService); |
|
|
|
|
|
|
|
|
ngOnInit() { |
|
|
ngOnInit() { |
|
|
const source$ = interval(1000); |
|
|
const source$ = interval(1000); |
|
|
@ -87,7 +90,7 @@ There are two ways to do that. If you are not going to subscribe again, you may |
|
|
providers: [SubscriptionService], |
|
|
providers: [SubscriptionService], |
|
|
}) |
|
|
}) |
|
|
class DemoComponent implements OnInit { |
|
|
class DemoComponent implements OnInit { |
|
|
constructor(private subscription: SubscriptionService) {} |
|
|
private subscription = inject(SubscriptionService); |
|
|
|
|
|
|
|
|
ngOnInit() { |
|
|
ngOnInit() { |
|
|
this.subscription.addOne(interval(1000), console.log); |
|
|
this.subscription.addOne(interval(1000), console.log); |
|
|
@ -107,7 +110,7 @@ This will clear all subscriptions, but you will not be able to subscribe again. |
|
|
providers: [SubscriptionService], |
|
|
providers: [SubscriptionService], |
|
|
}) |
|
|
}) |
|
|
class DemoComponent implements OnInit { |
|
|
class DemoComponent implements OnInit { |
|
|
constructor(private subscription: SubscriptionService) {} |
|
|
private subscription = inject(SubscriptionService); |
|
|
|
|
|
|
|
|
ngOnInit() { |
|
|
ngOnInit() { |
|
|
this.subscription.addOne(interval(1000), console.log); |
|
|
this.subscription.addOne(interval(1000), console.log); |
|
|
@ -131,8 +134,7 @@ Sometimes, you may need to unsubscribe from a particular subscription but leave |
|
|
}) |
|
|
}) |
|
|
class DemoComponent implements OnInit { |
|
|
class DemoComponent implements OnInit { |
|
|
countSubscription: Subscription; |
|
|
countSubscription: Subscription; |
|
|
|
|
|
private subscription = inject(SubscriptionService); |
|
|
constructor(private subscription: SubscriptionService) {} |
|
|
|
|
|
|
|
|
|
|
|
ngOnInit() { |
|
|
ngOnInit() { |
|
|
this.countSubscription = this.subscription.addOne( |
|
|
this.countSubscription = this.subscription.addOne( |
|
|
@ -159,8 +161,7 @@ You may want to take control of a particular subscription. In such a case, you m |
|
|
}) |
|
|
}) |
|
|
class DemoComponent implements OnInit { |
|
|
class DemoComponent implements OnInit { |
|
|
countSubscription: Subscription; |
|
|
countSubscription: Subscription; |
|
|
|
|
|
private subscription = inject(SubscriptionService); |
|
|
constructor(private subscription: SubscriptionService) {} |
|
|
|
|
|
|
|
|
|
|
|
ngOnInit() { |
|
|
ngOnInit() { |
|
|
this.countSubscription = this.subscription.addOne( |
|
|
this.countSubscription = this.subscription.addOne( |
|
|
@ -186,7 +187,7 @@ Please use `isClosed` getter to check if `closeAll` was called before. |
|
|
providers: [SubscriptionService], |
|
|
providers: [SubscriptionService], |
|
|
}) |
|
|
}) |
|
|
class DemoComponent implements OnInit { |
|
|
class DemoComponent implements OnInit { |
|
|
constructor(private subscription: SubscriptionService) {} |
|
|
private subscription = inject(SubscriptionService); |
|
|
|
|
|
|
|
|
ngOnInit() { |
|
|
ngOnInit() { |
|
|
this.subscription.addOne(interval(1000), console.log); |
|
|
this.subscription.addOne(interval(1000), console.log); |
|
|
|