Wanikani Open Framework [developer thread]

It works as expected. I have no snags to report.

I am adding more details to my previous response. The solution works best when the modifications to the value map are done in a .then() method attached to the promise that is returned from prepare(). The coding pattern is.

// value_map is an object meant to be modified by prepare()
function prepare(value_map){
    var promise_list = [];
    if (data1_is_needed){
        promise_list.push(load_data1)
    };
    if (data2_is_needed){
        promise_list.push(load_data2)
    };
    //
    // more data is loaded if needed
    //
    return Promise.all(promise_list).then(function(){set_value(value_map)});

    function set_value(value_map){
        value_map.property1 = value1;
        value_map.property2 = value2;
        //
        // modifying/setting more properties as needed
        //
    };
}

Calling set_value(value_map) from this .then() method ensures the property values are computed after the data is loaded and set before filter_func(value_map) is applied to items. This is exactly what is needed.

I couldn’t remember if we have a thread for CS chat, so I’m posting here instead. I’m taking a web development class next semester! It’s only basic stuff, but I am excited to learn to understand the things I already know a bit deeper, and fill in the holes that I have missed.

3 Likes

Maybe we should. Congrats! I hope you find it edifying, my CS classes left a lot to be desired re: best practices.

1 Like

Nice! Still keeping in mind what we talked about in email.

1 Like

@Mods could you unlock this thread?

https://community.wanikani.com/t/random-software-development-discussion/19564

1 Like

Sure, it’s unlocked now.

2 Likes

Thank you!

1 Like