Using ChangeDetectorRef in AsyncPipe


#1

Hello,
i’m struggling with AsyncPipe from Angular2.
I would like to perform something like that :

import { Injectable, ChangeDetectorRef } from '@angular/core';
import { AsyncPipe } from '@angular/common';
...

@Injectable()
export class ProfileDataProvider {
	
	public profile: any;

	constructor( ..., public cdr: ChangeDetectorRef) {

		.......

		this.profile = new AsyncPipe(cdr).transform(...);
	}

}

But I don’t know how to built an AsyncPipe in my TS knowing that i’m not in a component but in a custom provider.

Have you got an idea to built a pipe like this ?


#2

Here is an example of Async Pipe


#3

Thank you for your time, but I already know how to use AsyncPipe in templates.
My problem is how to use them in providers ?


#4

Pretty sure, that you would not use an async pipe inside of a provider.
The pipes are meant to be used in your templates,


#5

Okay, thank you.
I will do without it then.

Do I have to, in any case, create another variable: any and update it each time the subscribe function of my Observable send me a new value ?
I just wanted to put an async value in an alert component.