Options
All
  • Public
  • Public/Protected
  • All
Menu

Class SyncContext

receives change messages and updates collections.

Hierarchy

  • SyncContext

Hierarchy-Diagram

Index

Constructors

constructor

  • captures option values forming a GetQuery.

    constructor

    Parameters

    • Rest ...options: object[]

      to merge.

    Returns SyncContext

Properties

Private compareFn

compareFn: JsonCompareFn<any>

when set, defines sorting of collection.

Private filterFn

filterFn: JsonFilterFn<any>

when set, defines filtering of collection.

Private getQuery

getQuery: GetQuery

relevant parameters for paging, filtering and sorting.

type

{Relution.livedata.GetQuery}

Private lastInsertionPoint

lastInsertionPoint: number

used to speed up insertion point when doing consecutive insertions into sorted ranges.

Private pageSize

pageSize: number

limit of getQuery captured at construction time.

Methods

fetchMore

  • fetchMore(collection: Collection, options?: any): any
  • reads an additional page of data into the collection.

    When async processing is done, a more attribute is set on the options object in case additional data might be available which can be loaded by calling this method again. Likewise an end attribute is set if the data is fully loaded.

    see

    Collection#fetchMore()

    Parameters

    • collection: Collection

      to load data into.

    • Default value options: any = {}

      such as pageSize to retrieve.

    Returns any

    promise of the load operation.

fetchNext

  • fetchNext(collection: Collection, options?: any): any
  • reads the next page of data into the collection.

    see

    Collection#fetchNext()

    Parameters

    • collection: Collection
    • Default value options: any = {}

      such as pageSize to retrieve.

    Returns any

    promise of the load operation.

fetchPrev

  • fetchPrev(collection: Collection, options?: any): any
  • reads the previous page of data into the collection.

    see

    Collection#fetchPrev()

    Parameters

    • collection: Collection
    • Default value options: any = {}

      such as pageSize to retrieve.

    Returns any

    promise of the load operation.

Private fetchRange

  • fetchRange(collection: Collection, options?: any): any
  • reads a page of data into the collection.

    When async processing is done, a next/prev attribute is set on the options object in case additional pages might be available which can be loaded by calling this method again.

    Parameters

    • collection: Collection

      to load data into.

    • Default value options: any = {}

      incl. offset and limit of page to retrieve.

    Returns any

    promise of the load operation.

filterAttributes

  • filterAttributes<T>(attrs: T[], options?: any): T[]
  • Type parameters

    • T

    Parameters

    • attrs: T[]
    • Optional options: any

    Returns T[]

Private insertionPoint

  • insertionPoint(attributes: any, models: Model[]): number
  • computes the insertion point of attributes into models sorted by compareFn.

    This is used to compute the at-index of backbone.js add() method options when adding models to a sorted collection.

    Parameters

    • attributes: any

      being inserted.

    • models: Model[]

      sorted by compareFn.

    Returns number

    insertion point.

Private insertionPointBinarySearch

  • insertionPointBinarySearch(attributes: any, models: Model[], start: number, end: number): number
  • performs a binary search for insertion point of attributes into models[start:end] sorted by compareFn.

    Parameters

    • attributes: any

      being inserted.

    • models: Model[]

      sorted by compareFn.

    • start: number

      inclusive index of search interval.

    • end: number

      exclusive index of search interval.

    Returns number

    insertion point.

onMessage

  • receives change messages.

    Change messages are communicated by the SyncStore indirectly triggering a sync:channel event. This happens regardless of whether the change originates local or remote. The context then alters the backbone data incorporating the change.

    Parameters

    Returns void

processAttributes

  • processAttributes<T>(attrs: T[], options?: any): T[]
  • Type parameters

    • T

    Parameters

    • attrs: T[]
    • Optional options: any

    Returns T[]

rangeAttributes

  • rangeAttributes<T>(attrs: T[], options?: any): T[]
  • Type parameters

    • T

    Parameters

    • attrs: T[]
    • Optional options: any

    Returns T[]

sortAttributes

  • sortAttributes<T>(attrs: T[], options?: any): T[]
  • Type parameters

    • T

    Parameters

    • attrs: T[]
    • Optional options: any

    Returns T[]

Generated using TypeDoc