PatternsMake Your App Repeatable

Make Your App Repeatable

Give your app a level and a next unit with the shared Loop, so every visit is new.

Aksa is built on repetition: the same habit, again tomorrow. An app that shows the same screen every day gives the person no reason to come back. The Loop in aksa-mini.js gives every app a simple shape: a round is one finished unit of the habit, finishing a round unlocks the next one, and rounds add up to levels.

All the official starter apps use it. See the Examples.

The Idea

  • A round advances only when it is completed, never when the app is opened. Opening the app twice before finishing shows the same unit. This keeps levels honest: a person cannot gain a level by opening and closing the app.
  • Content apps walk a real sequence: a verse, a decade, a puzzle, a prompt. The next unit unlocks when this one is done.
  • Counter apps complete one round for each day the daily target is met, and show a short note that stays the same all day.
  • Level comes from completed rounds: 0, 3, 7, 14, 30, 60, 100 and 200.

The Loop In Code

js
const A = AksaMini;

A.loop("quran", {
  unit: "Ayah",                          // the label in the strip: "Ayah 12"
  seed: () => daysAlreadyDone,           // rounds to start from for people with history
}).then((loop) => {
  const index = loop.unit(AYAT.length);  // which unit to show right now
  show(AYAT[index]);
  loop.render(document.getElementById("loop"));
  button.onclick = () =>
    loop.complete().then((r) => {        // r = { advanced, rounds, level, leveledUp }
      loop.render(document.getElementById("loop"), r);
      show(AYAT[loop.unit(AYAT.length)]);
    });
});
CallWhat it does
AksaMini.loop(key, options)Loads the loop for your app. Returns a promise of the loop.
loop.unit(length, shuffle)The index of the unit to show. Sequential by default. With shuffle: true it never repeats inside a cycle.
loop.complete()Finishes the current round and returns { advanced, rounds, level, leveledUp }.
loop.render(element, result)Draws the Level strip, with an All Levels list. Pass the result of complete() to show the level-up line.
loop.rounds(), loop.level()The completed rounds, and the level with its name and what is needed next.
loop.doneToday()true when a round was already completed today.

Options

OptionMeaning
unitThe label in the strip, for example "Ayah" or "Day".
oncePerDayA round completes at most once per day. Use it for counter apps.
seedA number, or a function returning a number or a promise. Rounds to start from when the app has no loop yet.
namesExactly eight level names, to replace the defaults (Seed, Sprout, Steady, Rooted, Grounded, Flourishing, Evergreen, Timeless).

Do Not Lose People With History

When you add the Loop to an app that already has users, pass a seed that counts what they already did, for example the number of days they logged. They keep their level, and your content still starts at its beginning, so nobody skips what they never saw.

What To Put In A Round

Your app isOne round isExample
A reading or recitationOne passage readQur'an Daily
A practice with a countOne finished setDzikir Counter
A puzzleOne solved puzzleDaily Puzzle
A daily targetOne day the target is metWater Intake

Rules For Your Content

  • Real sources only for scripture or liturgy. Fetch the text from a source you can cite at build time, embed it, and name it on the page. Never type scripture from memory.
  • No claims you cannot back. No medical, religious-ruling or spiritual-reward promises in notes you write.
  • No network at run time. Everything is embedded in the one file.

Ready To Build Or Ship?

Check your files, preview on an iPhone frame, and submit in the Developer Studio.