Promises

Events that are likely expected to happen have a corresponding promise. Also other processes are exposed with have promises. The promise will let you wait for things to happen or if it already has happened execute instantly. It also executes asynchronously, which allows the code execution to continue.

The promise is always exposed on the object that it relates to. Some methods may also return a related promise, so that you may wait for the method to be resolved.

<script>
    var weavy = new Weavy({
        jwt: '{server_generated_jwt_token}'
    });
    weavy.whenLoaded().then(function () {
        /* Executed after init */
    });
</script>
You can use Promise.all() to wait for multiple promises at once.

Available promises

Weavy instance promises

weavy.whenReady()Resolved when frame checks are done. Rejected if frame check fails.
weavy.whenLoaded()Resolved when data has loaded from the server and DOM nodes has been built.
weavy.authentication.whenAuthenticated()Resolved when user identity has been established, which may also be anonymous. Rejected if failed.
weavy.authentication.whenAuthorized()Resolved when a user is signed in.

Space promises

space.whenLoaded()Resolved when data for the space has loaded from the server.
space.whenBuilt()Resolved when the optional space container has been built.

App promises

app.whenLoaded()Resolved when data for the app has loaded from the server.
app.whenBuilt()Resolved when the DOM nodes has been built.
app.panel.whenReady()Resolved when the frame has connected via postMessage.
app.panel.whenLoaded()Resolved when the frame document has fully loaded and triggered the "load" event.