Skip to main content

Initializers

The initializers are helper methods to simplify environment initiation/communication.

Every initializer returns a Promise to the id of the initiated environment, or just the id.

Socket client initializer

This initializer is intended to connect from any environment to an environment which exposes a socket server connection.

It looks at the topology key of the options provided to the communication instance, and looks if a url for a socket server is provided for this environment. (the node environments are initialized by the engineer cli. read more about it at [[utils.engineer#^run_node_envs]])

Iframe initializer

This initialized is intended to run from an environment with DOM available. It receives an iframe element, and loads the engine environment on that iframe. It uses the html generated by engineer. read more about it at [[utils.engineer#^compile_webpack]].

If a user decides to provide managed:true to the initializer, it will react to changes in the hash params of the iframe url, and is managed by the ManagedIframe class exported @wixc3/engine-core

A user has also the option to use the deferredIframeInitializer, which will return the environment id, and the initialize action.

Worker initializer

This initializer is intended to run from the main browser thread. It will initiate a new Worker instance, and load the relevant engine environment and feature there. It uses the js file generated by engineer, read more about it at [[utils.engineer#^compile_webpack]].

IPC client initializer

This initializer is intended to run from a node process. The node environment manager ([[utils.engineer#^run_node_envs]]) is providing to all node environments a method to communicate between them using an IPC protocol. It provides to all communiction instances a record of all environments and hosts.

This initialized states that the current environment wishes to receive messages from the other environment (since it's already registered in that point)