File

libs/open-layers/src/lib/services/mapid.service.ts

Description

Service to hold the corresponding map id

Index

Properties
Methods

Methods

Public getId
getId()

Returns the map id in an observable

Returns : Observable<string>

Observable of the map id

Public setId
setId(id: string)

Sets the map id

Parameters :
Name Type Optional Description
id string No

the map id

Returns : void

Properties

Private id
Type : string
Private subject
Type : Subject<string>
Default value : new Subject()
import { Injectable } from '@angular/core';
import { Observable, of, Subject } from 'rxjs';

/**
 * Service to hold the corresponding map id
 */
@Injectable({
  providedIn: 'root'
})
export class OlMapId {

  private id: string;

  private subject: Subject<string> = new Subject();

  /**
   * Returns the map id in an observable
   *
   * @returns Observable of the map id
   */
  public getId(): Observable<string> {
    return this.id ? of(this.id) : this.subject;
  }

  /**
   * Sets the map id
   *
   * @param id the map id
   */
  public setId(id: string) {
    this.id = id;
    this.subject.next(id);
    this.subject.complete();
  }
}

result-matching ""

    No results matching ""