We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

Promises calling other functions

Home Forums Puzzles Promises calling other functions

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #71841
    scatman2513
    Participant

    I have a heavy procedure that blocks my main thread too long. I want to use promises in my function to call other functions when they are finished. I have this example below as code, but I need to implement it with puzzles.

    I tried some things (see image in attachment) in puzzles but it never works as I fail to return a promise resolved() value. The documentation didnt help me.
    Is this possible with Verge3d puzzles or am I doing it wrong?

    code template:

    function init() {
        return new Promise((resolve, reject) => {
            setup().then(() => {
                render();
                resolve();
            }).catch(error => {
                reject(error);
            });
        });
    }
    
    function setup() {
        return new Promise((resolve, reject) => {
            resolve();
        });
    }
    
    function render() {
    }
    
    init().then(() => {
        console.log("Render finished");
    }).catch(error => {
        console.error("error:", error);
    });
    • This topic was modified 9 months, 1 week ago by scatman2513.
    Attachments:
    You must be logged in to view attached files.
    #71845
    kdv
    Participant

    but I need to implement it with puzzles.

    You can’t do it just with puzzles. No puzzles for that except exec script.

    Puzzles and JS coding. Fast and expensive.

    If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.