API Docs for: 0.1.1
Show:

flatworld.mapApi Class

Singleton. Uses JSON only data flow

Item Index

Methods

_doFetch

(
  • fetchType
  • type
  • params
)
Promise private

Does the actual fetch from the API endpoint

Parameters:

  • fetchType String

    post or get

  • type String

    name of the endpoint

  • params Array

    Params that are sent to the callbacks that have been attached to handle this API data. E.g. at least the POST data that will be sent to server needs to be set in the callback to the object.body property.

Returns:

Promise:

The result of the fetch

add

(
  • type
  • cb
  • baseUrl
)

Add a new mapApi endpoint

Parameters:

  • type String

    Basically the name of the mapAPI. Like 'moveUnit'.

  • cb Function

    Callback that returns the data that is sent to this API endpoint. Callback gets these parameters

    1. request type: post, get etc.
    2. completeData: { baseUrl, cbs }
    3. params: params that were sent to the mapAPI function as extra, like in post(type, params) HAS to return: {}.body = the data to be sent {}.url = url where the data is sent to
  • baseUrl String

    The url where the mapApi queries are sent to

get

(
  • name
  • params
)
Promise

Get data from server

Parameters:

  • name String

    The indentifier for this API call / endpoint

  • params Array

    Params that are sent to the callbacks that have been attached to handle this API data

Returns:

Promise:

ES6 native Promise as the API advances

getAllAPIs

() Object

Just returns all API endpoint definitions to be checked or modified as pleased. Only for advanced use.

Returns:

Object:

returns object that hosts all the API endpoint definitions

post

(
  • name
  • params
)
Promise

Send data to server

Parameters:

  • name String

    The indentifier for this API call / endpoint

  • params Array

    Params that are sent to the callbacks that have been attached to handle this API data. E.g. at least the POST data that will be sent to server needs to be set in the callback to the object.body property.

Returns:

Promise:

ES6 native Promise as the API advances

remove

(
  • type
)

Removes mapApi endpoint

Parameters:

  • type String

    Basically the name of the mapAPI. Like 'moveUnit'.

update

(
  • type
  • cb
  • what
)

Add a new mapApi endpoint

Parameters:

  • type String

    Basically the name of the mapAPI. Like 'moveUnit'.

  • cb Function

    Callback that returns the data that is sent to this API endpoint

  • what Function

    The update made