File

src/app/models/loader.model.ts

Index

Properties
Methods

Methods

close
close()
Returns : void
error
error(message: string)
Parameters :
Name Type Optional
message string no
Returns : void
setVisibility
setVisibility(value: boolean)
Parameters :
Name Type Optional
value boolean no
Returns : void
success
success(message: string)
Parameters :
Name Type Optional
message string no
Returns : void

Properties

closable
closable:
Default value : false
completion
completion: CompletionState
Type : CompletionState
message
message: string
Type : string
Default value : 'Loading...'
states
states: object
Type : object
Default value : { visibility: VisibilityState, completion: CompletionState }
visibility
visibility: VisibilityState
Type : VisibilityState
enum VisibilityState {
  VISIBLE,
  HIDDEN
}

enum CompletionState {
  NONE,
  SUCCESS,
  ERROR
}

export class LoaderModel {
  closable = false;
  states = {
    visibility: VisibilityState,
    completion: CompletionState
  };

  visibility: VisibilityState;
  completion: CompletionState;

  message = 'Loading...';

  setVisibility(value: boolean) {
    this.completion = this.states.completion.NONE;
    this.visibility = value
      ? this.states.visibility.VISIBLE
      : this.states.visibility.HIDDEN;
    this.closable = !value;
  }

  success(message: string) {
    if (!message || message.length < 1) return;
    this.message = message;
    this.completion = this.states.completion.SUCCESS;
    this.visibility = this.states.visibility.VISIBLE;
    this.closable = true;
  }

  error(message: string) {
    if (!message || message.length < 1) return;
    this.message = message;
    this.completion = this.states.completion.ERROR;
    this.visibility = this.states.visibility.VISIBLE;
    this.closable = true;
  }

  close() {
    if (this.closable) {
      this.message = null;
      this.completion = this.states.completion.NONE;
      this.visibility = this.states.visibility.HIDDEN;
    }
  }
}

results matching ""

    No results matching ""