File

projects/common/lib/services/container.service.ts

Index

Properties
Methods

Constructor

constructor()

Methods

setIsLoading
setIsLoading(isLoading: boolean)

If no parameter is passed, it sets the spinner active

Parameters :
Name Type Optional Default value
isLoading boolean No true
Returns : void
setSubmitLabel
setSubmitLabel(label: string)

If no parameter is passed, the default label is 'Continue'

Parameters :
Name Type Optional Default value
label string No DefaultSubmitLabel
Returns : void
setUseDefaultColor
setUseDefaultColor(defaultColor: boolean)

If no parameter is passed, it uses the default color

Parameters :
Name Type Optional Default value
defaultColor boolean No true
Returns : void
submitButtonClicked
submitButtonClicked()
Returns : void

Properties

$continueBtn
Default value : this.$continueBtnSubject.asObservable()
$continueBtnSubject
Type : Subject<null>
Default value : new Subject()
$isLoading
Default value : this.$isLoadingSubject.asObservable()
$isLoadingSubject
Type : BehaviorSubject<boolean>
Default value : new BehaviorSubject( false )
$submitLabel
Default value : this.$submitLabelSubject.asObservable()
$submitLabelSubject
Type : BehaviorSubject<string>
Default value : new BehaviorSubject( DefaultSubmitLabel )
$useDefaultColor
Default value : this.$useDefaultColorSubject.asObservable()
$useDefaultColorSubject
Type : BehaviorSubject<boolean>
Default value : new BehaviorSubject( true )
import { Injectable } from '@angular/core';
import { BehaviorSubject, Subject } from 'rxjs';

export const DefaultSubmitLabel: string = 'Continue';

@Injectable({
  providedIn: 'root'
})
export class ContainerService {

  $isLoadingSubject: BehaviorSubject<boolean> = new BehaviorSubject( false );
  $submitLabelSubject: BehaviorSubject<string> = new BehaviorSubject( DefaultSubmitLabel );
  $useDefaultColorSubject: BehaviorSubject<boolean> = new BehaviorSubject( true );
  $continueBtnSubject: Subject<null> = new Subject();

  // Observables
  $isLoading = this.$isLoadingSubject.asObservable();
  $submitLabel = this.$submitLabelSubject.asObservable();
  $continueBtn = this.$continueBtnSubject.asObservable();
  $useDefaultColor = this.$useDefaultColorSubject.asObservable();

  constructor() { }

  /** If no parameter is passed, the default label is 'Continue' */
  setSubmitLabel( label: string  = DefaultSubmitLabel ) {
    this.$submitLabelSubject.next( label );
  }

  /** If no parameter is passed, it uses the default color */
  setUseDefaultColor( defaultColor: boolean = true ) {
    this.$useDefaultColorSubject.next( defaultColor );
  }

  /** If no parameter is passed, it sets the spinner active */
  setIsLoading( isLoading: boolean = true ) {
    this.$isLoadingSubject.next( isLoading );
  }

  submitButtonClicked() {
    this.$continueBtnSubject.next();
  }
}

result-matching ""

    No results matching ""