Skip to main content

Core concepts

Data comes to youโ€‹

You do not fetch data. A screen observes (or a presenter is subscribed to), and the SDK calls your render method with the current data, then again every time it changes. After a purchase, the Shop, the Header and the Character screen all receive the new balances from that one purchase; you call nothing else.

Don't keep your own copy
// โŒ WRONG โ€” this copy goes stale as soon as the server changes it
private long coreDust;
private void Start() => coreDust = header.Current.Currencies[0].Amount;
// โœ… CORRECT โ€” subscribe once and render every change
private async void OnEnable()
{
lifetime = new CancellationTokenSource();
var token = lifetime.Token;
var headerSub = await header.SubscribeAsync(Render);
if (token.IsCancellationRequested)
{
headerSub.Dispose(); // the page closed while subscribing
return;
}
subscription = headerSub;
}

Views and snapshotsโ€‹

What you receive is read-only:

  • a screen contract gives a view (ProjectVShopView and so on). It always holds the last confirmed data. IsLoading is true only until the first data arrives, and LoadError explains a failed first load.
  • a presenter gives a snapshot (ProjectVHeaderSnapshot and so on) with a Status, the data, and an Error when something failed.

Current returns the latest one, for code that renders outside the callback.

The server decidesโ€‹

The backend decides balances, inventory, stamina, levels, upgrade costs, shop limits, mission locks, rewards and stars. Show what the SDK gives you. Previews the SDK provides (EXP preview, drop preview, stamina countdown) are for display only; never turn them into values of your own.

One tap, one requestโ€‹

  • Opening a screen usually sends no request; the data is already loaded.
  • A command sends one request, and its result updates every screen that shows the changed data.
  • Tapping again while a command runs does not send it twice.

So: no refresh after a command, no refresh when a scene opens, no periodic reload.

Sign-out and account switchingโ€‹

After logout, account deletion or signing in as someone else, all data from the previous account is cleared. Old views and snapshots must not drive UI any more; the screens receive the new account's data when it loads.

Lifetimeโ€‹

Screen contracts and presenters live as long as the app. Your page's Observe or SubscribeAsync lives with the page: create it when the page opens, dispose it when the page closes.

Next: Scene integration.