Documentation
    Preparing search index...

    Class Slice<T>

    An object to aid in constructing Datalynk requests

    Type Parameters

    • T extends Meta = any
    Index

    Constructors

    • An object to aid in constructing requests

      Type Parameters

      • T extends Meta = any

      Parameters

      • slice: string | number

        Slice ID to interact with

      • api: Api

        Api to send the requests through

      Returns Slice<T>

    Properties

    cache$: BehaviorSubject<T[]> = ...

    Cached slice data as an observable

    unsubscribe?: null | Unsubscribe

    Unsubscribe from changes, undefined if not subscribed

    Accessors

    • get cache(): T[]

      Cached slice data

      Returns T[]

    • set cache(cache: T[]): void

      Set cached data & alert subscribers

      Parameters

      • cache: T[]

      Returns void

    • get offlineEnabled(): undefined | boolean

      Is slice offline support enabled

      Returns undefined | boolean

    Methods

    • Count the returned rows

      Parameters

      • arg: string | object = 'id'

        Count argument

      Returns ApiCall<T>

    • Set the request type to delete

      Parameters

      • id: number | number[]

        ID(s) to delete

      Returns ApiCall<T>

    • Get slice information

      Parameters

      • Optionalreload: boolean

        Ignore cache & reload info

      Returns Promise<SliceInfo>

    • Set the request type to insert

      Parameters

      • rows: T | T[]

        Rows to be inserted into the slice

      Returns ApiCall<T>

    • Returns Promise<void>

    • Save multiple rows to the slice, automatically inserts/updates

      Parameters

      • rows: T | T[]

        Rows to add to slice

      Returns ApiCall<T>

    • Set the request type to select

      Parameters

      • Optionalid: number | number[]

        ID(s) to select, leaving blank will return all rows

      Returns ApiCall<T>

    • Synchronize cache with server

      Parameters

      • on: boolean = true

        Enable/disable events

      Returns undefined | BehaviorSubject<T[]>

      Cache which can be subscribed to

      const slice: Slice = new Slice<T>(Slices.Contact);
      slice.sync().subscribe((rows: T[]) => {});
    • Set the request type to update

      Parameters

      • rows: T | T[]

        Rows to be updated, each row must have an ID

      Returns ApiCall<T>