Class RestDataSource<EntityType>

Type Parameters

Hierarchy

Constructors

Properties

commitBaseParams: {} = {}

Extra parameters to send to the Foo/set

Type declaration

    creates: Record<string, SaveData<EntityType>> = {}
    data: Record<string, EntityType> = {}
    destroys: Record<string, DestroyData> = {}
    getIds: Record<string, GetData> = {}
    id: string
    persist: boolean = true

    Store data in the browser storage so it will persist across sessions

    setParams: {
        [key: string]: any;
    } = {}

    Extra /set parameters that will reset after commit

    Type declaration

    • [key: string]: any
    updates: Record<string, SaveData<EntityType>> = {}
    uri: string

    The base URI of the REST API. for example https://groupoffice.com/api

    Accessors

    Methods

    • Private

      Check's if we are up-to-date with the server and fetches updates if needed.

      If no state is returned by the data source this function will ignore states and the data source should then always refresh data.

      Type Parameters

      • T

      Parameters

      • serverState: undefined | string
      • retVal: T

      Returns Promise<T>

    • Ask for confirmation and delete entities by ID

      Parameters

      • ids: string[]

        The ID's to delete

      Returns Promise<false | unknown[]>

      Example

      const tbl = this.projectTable!,
      ids = tbl.rowSelection!.selected.map(index => tbl.store.get(index)!.id);

      const result = await jmapds("Project3")
      .confirmDestroy(ids);

      if(result != false) {
      btn.parent!.hide();
      }
    • Create entity

      Multiple calls will be joined together in a single call on the next event loop

      Parameters

      • data: Partial<EntityType>
      • Optional createId: string

        The create ID to use when committing this entity to the server

      Returns Promise<EntityType>

    • Protected

      Does the actual getting of entities. First checks if present in this onbject, otherwise it will be requested from the remote source.

      Returns Promise<void>

    • Parameters

      • path: string = ""
      • options: RequestInit = {}

      Returns Promise<any>

    • Parameters

      • id: number | number[]
      • path: string = ""
      • options: RequestInit = {}

      Returns Promise<any>

    • Parameters

      • path: string = ""
      • options: RequestInit = {}

      Returns Promise<any>

    • Protected

      Set's the local server state ID

      Setting it to undefined will reset the store.

      Parameters

      • state: undefined | string

      Returns Promise<undefined | boolean>

    • Get a single entity.

      Multiple calls will be buffered and returned together on the next event loop. This way multiple calls can be joined together in a single HTTP request to the server.

      Parameters

      • id: string

      Returns Promise<undefined | EntityType>

    • Update an entity

      Multiple calls will be joined together in a single call on the next event loop

      Parameters

      • id: string
      • data: Partial<EntityType>

      Returns Promise<EntityType>

    Generated using TypeDoc