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.
Maybe we should. Congrats! I hope you find it edifying, my CS classes left a lot to be desired re: best practices.
Nice! Still keeping in mind what we talked about in email.
@Mods could you unlock this thread?
https://community.wanikani.com/t/random-software-development-discussion/19564
Sure, itās unlocked now.
Thank you!