letela
→ awaitHolds a function at that line until a slow job has finished, then carries on.
letela <a slow job>Some jobs do not finish at once. Fetching a picture from the machine — or across a network — takes time, and your code has to wait for it. letela is the word that waits.
diri setshwantsho = letela tlisaSetshwantsho('letsatsi.png');
Without letela, the next line would run before the picture had arrived, and you would be trying to draw something that does not exist yet.
You do not need a second word. In other languages you must also write async above the function before await is allowed. Bopa does not ask that: when it sees letela inside a function, it marks that function for you. One word is the whole of it.
It only works inside a function. letela must sit inside a function declared with tiro. Outside one, Bopa says so in Setswana rather than leaving you to read an English message about a word you did write.
setaLoeto is waited for. Bopa waits for setaLoeto to finish before it draws the first frame, so fetching pictures inside setaLoeto is the right place — the canvas does not start drawing without them.
⚠ Inside
tshwantshait slows things down.tshwantshais waited for too, so aletelainside it holds up every frame. Fetch pictures once insetaLoeto, not over and over intshwantsha.
A loop that waits is not guarded. Bopa watches for loops that never finish and stops runaway ones. A loop with
letelainside it is left alone — it does not freeze the page, so the Emisa button still works. See thenakopage.
Examples
Section titled “Examples”diri letsatsi;
tiro setaLoeto() {
thalaKanefase(400, 240);
letsatsi = letela tlisaSetshwantsho('letsatsi.png');
bokamorago(245);
thalaSetshwantsho(letsatsi, 140, 40, 120, 120);
tlhalosa('Setshwantsho sa letsatsi se se thadilweng mo bogareng jwa kanefase e e bosetlha.');
}tiro setaLoeto() {
thalaKanefase(400, 240);
bokamorago(245);
diri letsatsi = letela tlisaSetshwantsho('letsatsi.png');
diri naledi = letela tlisaSetshwantsho('naledi.png');
thalaSetshwantsho(letsatsi, 40, 60, 120, 120);
thalaSetshwantsho(naledi, 240, 60, 120, 120);
tlhalosa('Letsatsi kwa molemeng le naledi kwa mojeng, ka bobedi di le mo kanefaseng e le nngwe.');
}