Core
Core JavaScript features
Integrate your JavaScript code with the basic functions of your AppMachine app. This page discusses the available functions and possible errors that lie at the basis of each JavaScript block.
Get Block Name
Get the current name of the block.
Errors
Here is a list of errors that can be thrown when calling this function in addition to generic errors:
INVALID_ARGUMENT
The 'caption' property is not defined on the block.
Get Property
Get a property by name from the current block.
Arguments
propertyName
String
✅
-
Errors
Here is a list of errors that can be thrown when calling this function in addition to generic errors:
INVALID_ARGUMENT
The provided propertyName
is not found.
Get Image Url
Get a public URL of an image, based on the given imageId
.
Image Resizing
By default the image URL that will be returned is the URL of the image in full resolution. We recommend using fixed dimensions for the width
and height
options when using high resolution images. This also improves performance and saves bandwidth.
Basic Example
Multiple Image sizes
It is also possible to use multiple image resolution depending on the device resolution or pixel density using image src sets. Read MDN guide for more information.
Result
Arguments
imageId
String
✅
-
dimensions
{ width: Number, height: Number }
-
Errors
Here is a list of errors that can be thrown when calling this function in addition to generic errors:
INVALID_ARGUMENT
imageId
is missing or the width
or height
isn't a number.
Show Loader
Show an overlay with a spinner.
Hide Loader
Hide the loader overlay that was shown by the showLoader
function.
Errors
Here is a list of errors that can be thrown when calling this function in addition to generic errors:
OPERATION_NOT_ALLOWED
There is no active loader.
Generic errors
UNKNOWN_ERROR
Unknown error occurred.
TIMEOUT_EXCEEDED
The app failed to respond within the set timeout.
UNKNOWN_FUNCTION
The function that was called doesn't exist.
VERSION_NOT_SUPPORTED
The function isn't supported in the current version of the app.
Last updated