Home Reference Source
import ServerCommunication from 'timer_app/src/helpers/serverCommunication.js'
public class | source

ServerCommunication

This class handle all the communication with the server Providing a set of methods that returns Promises

Constructor Summary

Public Constructor
public

constructor(baseUrl: string)

Member Summary

Public Members
public

Location of the api

Method Summary

Public Methods
public

Create a new timer

public

Delete a timer

public
public

Start a timer

public

Stop a timer

public

Change a property of a timer

Public Constructors

public constructor(baseUrl: string) source

Params:

NameTypeAttributeDescription
baseUrl string
  • optional
  • default: ''

Location of the api

Public Members

public baseUrl: string source

Location of the api

Public Methods

public createTimer(attrs: APITimer): Promise source

Create a new timer

Params:

NameTypeAttributeDescription
attrs APITimer

Return:

Promise

public deleteTimer(id: string): Promise source

Delete a timer

Params:

NameTypeAttributeDescription
id string

Return:

Promise

public getTimers(): Promise<Array<APITimer>> source

Return:

Promise<Array<APITimer>>

public startTimer(arg: Object): Promise source

Start a timer

Params:

NameTypeAttributeDescription
arg Object
arg.id string
arg.start number

Return:

Promise

public stopTimer(arg: Object): Promise source

Stop a timer

Params:

NameTypeAttributeDescription
arg Object
arg.id string
arg.stop number

Return:

Promise

public updateTimer(attrs: APITimer): Promise source

Change a property of a timer

Params:

NameTypeAttributeDescription
attrs APITimer

Return:

Promise