Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Entity<T>

A Class that defines the base Entity Model

example
//Most methods on the entity are fluent (chainable)
var job = new Entity('JobOrder').fields('title');
//the 'fields' function created a getter and setter for 'title'
job.title = 'My New Job';
job.save();

Type parameters

Hierarchy

Implements

  • Subscribable<T>
  • ISubscription

Indexable

[propName: string]: any

A Class that defines the base Entity Model

Index

Constructors

constructor

Properties

Protected $entity

$entity: EntityService<T>

Protected _fields

_fields: string[] = []

_isScalar

_isScalar: boolean

Protected broker

broker: EntityMessageBroker = EntityMessageBroker.getInstance()

closed

closed: boolean

descriptor

descriptor: any

hasError

hasError: boolean

isStopped

isStopped: boolean

observers

observers: Observer<T>[]

Protected operator

operator: Operator<any, T>

Protected source

source: Observable<any>

thrownError

thrownError: any

type

type: string

Static create

create: Function

Static filter

filter: filter

Static if

if: create

Static mergeAll

mergeAll: mergeAll

Static share

share: share

Static skip

skip: skip

Static take

take: take

Static throw

throw: create

Accessors

snapshot

  • get snapshot(): T

value

  • get value(): T

Methods

_subscribe

  • _subscribe(subscriber: any): Subscription

Protected _trySubscribe

  • _trySubscribe(subscriber: Subscriber<T>): TeardownLogic
  • Parameters

    • subscriber: Subscriber<T>

    Returns TeardownLogic

asObservable

  • asObservable(): Observable<T>
  • Returns Observable<T>

complete

  • complete(): void
  • Returns void

error

  • error(err: any): void
  • Parameters

    • err: any

    Returns void

fields

  • fields(...args: any[]): this
  • Define the fields to set or retrieve for the given entity. Getter and Setter methods will automagically be set up on the entity once the fields are defined.

    Parameters

    • Rest ...args: any[]

      Fields can either be sent as a list of arguments or as an Array.

    Returns this

forEach

  • forEach(next: function, PromiseCtor?: PromiseConstructor): Promise<void>
  • method

    forEach

    Parameters

    • next: function

      a handler for each value emitted by the observable

        • (value: T): void
        • Parameters

          • value: T

          Returns void

    • Optional PromiseCtor: PromiseConstructor

    Returns Promise<void>

    a promise that either resolves on observable completion or rejects with the handled error

get

  • Make http request to get entity. Objects 'data' property will be set to response, then promise will be resolved.

    Parameters

    • id: number

      Id of the Model to retrieve

    Returns Entity<T>

getValue

  • getValue(): T

hasValue

  • hasValue(): boolean

lift

  • lift<R>(operator: Operator<T, R>): Observable<R>
  • Type parameters

    • R

    Parameters

    • operator: Operator<T, R>

    Returns Observable<R>

next

  • next(value: T): void

once

  • once(): Observable<T>

params

  • params(object: any): this
  • Will merge object into the entity's parameter to be sent in any http request.

    Parameters

    • object: any

      all additional parameters

    Returns this

patch

  • patch(data: any, ignoreEvent?: boolean): Entity<T>
  • Used to update only properties sent in the packet

    Parameters

    • data: any

      packet of data to update object with

    • Default value ignoreEvent: boolean = false

    Returns Entity<T>

pipe

  • pipe(): Observable<T>
  • pipe<A>(op1: OperatorFunction<T, A>): Observable<A>
  • pipe<A, B>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>): Observable<B>
  • pipe<A, B, C>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>): Observable<C>
  • pipe<A, B, C, D>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>): Observable<D>
  • pipe<A, B, C, D, E>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>): Observable<E>
  • pipe<A, B, C, D, E, F>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>, op6: OperatorFunction<E, F>): Observable<F>
  • pipe<A, B, C, D, E, F, G>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>, op6: OperatorFunction<E, F>, op7: OperatorFunction<F, G>): Observable<G>
  • pipe<A, B, C, D, E, F, G, H>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>, op6: OperatorFunction<E, F>, op7: OperatorFunction<F, G>, op8: OperatorFunction<G, H>): Observable<H>
  • pipe<A, B, C, D, E, F, G, H, I>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>, op6: OperatorFunction<E, F>, op7: OperatorFunction<F, G>, op8: OperatorFunction<G, H>, op9: OperatorFunction<H, I>): Observable<I>
  • Returns Observable<T>

  • Type parameters

    • A

    Parameters

    • op1: OperatorFunction<T, A>

    Returns Observable<A>

  • Type parameters

    • A

    • B

    Parameters

    • op1: OperatorFunction<T, A>
    • op2: OperatorFunction<A, B>

    Returns Observable<B>

  • Type parameters

    • A

    • B

    • C

    Parameters

    • op1: OperatorFunction<T, A>
    • op2: OperatorFunction<A, B>
    • op3: OperatorFunction<B, C>

    Returns Observable<C>

  • Type parameters

    • A

    • B

    • C

    • D

    Parameters

    • op1: OperatorFunction<T, A>
    • op2: OperatorFunction<A, B>
    • op3: OperatorFunction<B, C>
    • op4: OperatorFunction<C, D>

    Returns Observable<D>

  • Type parameters

    • A

    • B

    • C

    • D

    • E

    Parameters

    • op1: OperatorFunction<T, A>
    • op2: OperatorFunction<A, B>
    • op3: OperatorFunction<B, C>
    • op4: OperatorFunction<C, D>
    • op5: OperatorFunction<D, E>

    Returns Observable<E>

  • Type parameters

    • A

    • B

    • C

    • D

    • E

    • F

    Parameters

    • op1: OperatorFunction<T, A>
    • op2: OperatorFunction<A, B>
    • op3: OperatorFunction<B, C>
    • op4: OperatorFunction<C, D>
    • op5: OperatorFunction<D, E>
    • op6: OperatorFunction<E, F>

    Returns Observable<F>

  • Type parameters

    • A

    • B

    • C

    • D

    • E

    • F

    • G

    Parameters

    • op1: OperatorFunction<T, A>
    • op2: OperatorFunction<A, B>
    • op3: OperatorFunction<B, C>
    • op4: OperatorFunction<C, D>
    • op5: OperatorFunction<D, E>
    • op6: OperatorFunction<E, F>
    • op7: OperatorFunction<F, G>

    Returns Observable<G>

  • Type parameters

    • A

    • B

    • C

    • D

    • E

    • F

    • G

    • H

    Parameters

    • op1: OperatorFunction<T, A>
    • op2: OperatorFunction<A, B>
    • op3: OperatorFunction<B, C>
    • op4: OperatorFunction<C, D>
    • op5: OperatorFunction<D, E>
    • op6: OperatorFunction<E, F>
    • op7: OperatorFunction<F, G>
    • op8: OperatorFunction<G, H>

    Returns Observable<H>

  • Type parameters

    • A

    • B

    • C

    • D

    • E

    • F

    • G

    • H

    • I

    Parameters

    • op1: OperatorFunction<T, A>
    • op2: OperatorFunction<A, B>
    • op3: OperatorFunction<B, C>
    • op4: OperatorFunction<C, D>
    • op5: OperatorFunction<D, E>
    • op6: OperatorFunction<E, F>
    • op7: OperatorFunction<F, G>
    • op8: OperatorFunction<G, H>
    • op9: OperatorFunction<H, I>

    Returns Observable<I>

remove

  • remove(): Promise<AxiosResponse>
  • Sends a request to delete the entity

    Returns Promise<AxiosResponse>

save

  • save(): Promise<AxiosResponse>
  • Create or Updates the entity based on the presence of an 'id' property

    Returns Promise<AxiosResponse>

set

subscribe

  • subscribe(observer?: PartialObserver<T>): Subscription
  • subscribe(next?: function, error?: function, complete?: function): Subscription
  • Parameters

    • Optional observer: PartialObserver<T>

    Returns Subscription

  • Parameters

    • Optional next: function
        • (value: T): void
        • Parameters

          • value: T

          Returns void

    • Optional error: function
        • (error: any): void
        • Parameters

          • error: any

          Returns void

    • Optional complete: function
        • (): void
        • Returns void

    Returns Subscription

toPromise

  • toPromise<T>(this: Observable<T>): Promise<T>
  • toPromise<T>(this: Observable<T>, PromiseCtor: PromiseConstructor): Promise<T>
  • toPromise<T>(this: Observable<T>, PromiseCtor: PromiseConstructorLike): Promise<T>
  • Type parameters

    • T

    Parameters

    • this: Observable<T>

    Returns Promise<T>

  • Type parameters

    • T

    Parameters

    • this: Observable<T>
    • PromiseCtor: PromiseConstructor

    Returns Promise<T>

  • Type parameters

    • T

    Parameters

    • this: Observable<T>
    • PromiseCtor: PromiseConstructorLike

    Returns Promise<T>

unsubscribe

  • unsubscribe(): void
  • Returns void

Generated using TypeDoc