Wix.Worker

addEventListener

addEventListener(eventName, handler)

Important:
Check the specific SDK version for each event. Events that are available in SDK versions higher than 1.45.0 are not supported in the old Editor. Learn more.

Allows the worker component to listen to events that happen in the editor or website.

Make sure to register event listeners when the document loads, since previous listeners might be invalidated when we load your app.

Parameters:

NameTypeDescription

The events that you can currently listen to are:

EventEvent DataDescription

currentMember

currentMember(callback)

Retrieves the current Site Member, if one exists.

Parameters:

NameTypeDescription

Value passed to callback:

An object containing the user’s details:

NameTypeDescription
getSiteInfo

getSiteInfo(callback)

Retrieves information about the host site.

Parameters:

NameType Description

Value passed to callback:

An object containing the site info:

NameTypeDescription 
getSiteMap

getSiteMap(callback)

Retrieves all items in the site structure, including:

  • Items in the site’s menu – pages (including subpages), links, and menu headers.
  • Hidden pages – pages that are in the site, but not in the site menu. For example, a “Thank You” page that’s shown only after a site visitor makes a purchase.
Note:
Use this method instead of getSitePages, which is now deprecated.

Parameters:

NameTypeDescription

Value passed to callback:

An array of objects, where each object represents an item in the site structure.

Warning:
To use this object later (for example, if you want to navigate to a link on the user’s site), save this object in your database as is – don’t change it in any way.

Each object contains data about the item. The data sent depends on the item – check out our examples below.

NameTypeDescription

Here’s an example of an array passed to the callback:

Example:

isApplicationInstalled

isApplicationInstalled(appDefinitionId, callback)

Allows you to check if another one of your apps is installed.

Parameters:

NameTypeDescription

Example:

isAppSectionInstalled

isAppSectionInstalled(sectionId,[options],callback)

Allows you to check if the user added one of your app’s hidden or custom pages (like a thank you or checkout page).

Parameters:

NameTypeDescription

Example:

removeEventListener

removeEventListener (eventName, callBackOrId)

Allows to remove previously assigned event listeners that were specified using Wix.addEventListener.

Parameters:

NameTypeDescription
Utils.getDeviceType

Utils.getDeviceType( ) → String

Returns a String which represents the current device type: Desktop or Mobile.

Utils.getInstanceId

Utils.getInstanceId( ) → String

Returns a String which represents the app instance Id.

Utils.getIpAndPort

Utils.getIpAndPort( ) → String

Returns a String which represents the app IP and port.

Utils.getViewMode

Utils.getViewMode( ) → String

Returns a String which represents the current view mode.

Utils.navigateToSection

Utils.navigateToSection(options, onFailure)

Navigates to your page component – either to the page component itself or to one of your app’s internal pages.

Parameters:

NameTypeDescription
PubSub.publish

PubSub.publish(eventName, data, isPersistent)

Broadcasts an event to other Site components of a multicomponent app. If the components span multiple pages, they will be notified when they are rendered.

Parameters:

NameTypeDescription
PubSub.subscribe

PubSub.unbscribe(eventName, callBack, receivePastEvents)

Subscribes to events from other components of a multicomponent app. If the components span multiple pages, they will be notified once they are rendered. It is also possible to receive all notifications prior to rendering by specifying a flag when subscribing to events. If the flag is set, the component will be notified immediately of any prior events of the type it is registered to receive.

Parameters:

NameTypeDescription
PubSub.unsubscribe

PubSub.unsubscribe(eventName, function)

Unsubscribes from receiving further events. The id from the initial subscribe call is used to unsubscribe from further notifications.

Parameters:

NameTypeDescription
Deprecated

getSitePages

Note:
Now that this method is deprecated, use the getSiteMap method instead.

Retrieves all pages in this site. A page can be:

  • An item in the site’s menu – a page, subpage, external link, link to a page anchor, or menu header.
  • A hidden page/subpage – these pages are part of the site, but they’re not part of the site menu. For example, a “Thank You” page that’s shown only after a site visitor makes a purchase.

 

Parameters:

NameTypeDescription

Value passed to callback:

An array of objects, where each object represents a page in the site.

The objects are ordered according to the site’s structure shown in the Pages menu of the Wix Editor. If a page has subpages, they are passed as an array of objects nested inside the page object.

Each page/subpage object contains the following properties:

NameTypeDescription

Was this page helpful?

What can we do to improve it?

What did you like about it?