flatworld.mapApi Class
Singleton. Uses JSON only data flow
Methods
_doFetch
(
Promise
private
-
fetchType
-
type
-
params
Does the actual fetch from the API endpoint
Parameters:
Returns:
Promise:
The result of the fetch
add
(
-
type
-
cb
-
baseUrl
Add a new mapApi endpoint
Parameters:
-
type
StringBasically the name of the mapAPI. Like 'moveUnit'.
-
cb
FunctionCallback that returns the data that is sent to this API endpoint. Callback gets these parameters
- request type: post, get etc.
- completeData: { baseUrl, cbs }
- 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
StringThe url where the mapApi queries are sent to
get
(
Promise
-
name
-
params
Get data from server
Parameters:
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
(
Promise
-
name
-
params
Send data to server
Parameters:
Returns:
Promise:
ES6 native Promise as the API advances
remove
(
-
type
Removes mapApi endpoint
Parameters:
-
type
StringBasically the name of the mapAPI. Like 'moveUnit'.