mercredi 14 août 2019

How to model in UML an angular service with serveral Observable attribute

I try to documente my angular code. In a service that I have coded, I have several BehaviorSubject like this :

@Injectable
export class ExampleService {
    private sourceInfoA = new BehaviorSubject<String>(null);
    private sourceInfoB = new BehaviorSubject<String>(null);

    currentInfoA = this.sourceInfoA.asObservable();
    currentInfoB = this.sourceInfob.asObservable();

    constructor() { }

    changeInfoA(info: String){
         this.sourceInfoA.next(info);
    }

    changeInfoB(info: String){
         this.sourceInfoB.next(info);
    }

}

(This service is for instance called on the constructor for an ExampleComponent).

I try to read some documentation (like https://en.wikipedia.org/wiki/Observer_pattern) about the Observer design pattern, but I don't manage to see if i this patterns apply to my sevrice, and overall how can I modelize with this pattern my service.

Can someone help me or give me some indication on how the Observer Pattern can be modelized when we use some rxjs tools like in my case ?

(Sorry for my english, it's not my natural tongue).

Aucun commentaire:

Enregistrer un commentaire