Skip to main content

Presenter reference

There is one instance of each presenter for the whole app. Inject the interface into a view registered by your scene scope.

PresenterNamespace (SilverTiger.ProjectV.Unity.Presentation.*)Used by
IProjectVStartupPresenter.StartupLogin: admission, session restore, hydration
IProjectVAuthenticationPresenter.AuthenticationLogin: Guest, password, Google, Apple
IProjectVAccountPresenter.AccountAccount popup: logout, account deletion
IProjectVLobbyPresenter.LobbyLobby profile
IProjectVHeaderPresenter.HeaderTop bar: currencies, stamina countdown
IProjectVCharacterPresenter.CharacterCharacters, skills, equipment, skins, items
IProjectVAlliancePresenter.AllianceAlly selection
IProjectVCampaignPresenter.CampaignMission list, stars, entry
IProjectVShopPresenter.ShopOffers and purchases
IProjectVGameplayDataPresenter.GameplayMission scene: start data and settlement

Types shared by several presenters (recovery state, transaction confirmation, errors, typed IDs, UI-binding helpers) are on Shared types.

Prefer the screen contract

Lobby, Character, Alliance, Campaign and Shop also have a screen contract (IProjectVLobbyScreen and so on). A page observes one view and calls commands. Use the presenter only for what the contract does not cover yet.

The common shape​

Every screen presenter follows the same pattern:

ProjectVXxxSnapshot Current { get; } // latest snapshot, never null
Task<IDisposable> SubscribeAsync(Action<ProjectVXxxSnapshot> listener); // current value, then every change
Task<ProjectVXxxCommandResult> RefreshAsync(CancellationToken token); // where the screen has data
Task<ProjectVXxxCommandResult> SomeCommandAsync(..., CancellationToken token);
  • A snapshot carries a Status enum, the screen data (or null before it loads), an Error (or null) and, on data screens, a ProjectVScreenRecoveryState Recovery.
  • A command result carries Snapshot and IsSuccess. Always render the snapshot, even on failure; the previous usable data is kept.
  • A presenter listener may run off the Unity main thread. Switch to the main thread before touching Unity objects (for example with UniTask's await UniTask.SwitchToMainThread()). Screen contracts do this for you.
  • Exceptions mean a programming or lifecycle error (bad argument, wrong scene). Expected backend failures are values in Error.

Errors by presenter​

PresenterError typeShow the player
Startup, Authentication, Account, LobbyProjectV*ErrorLocalizationKey (for example projectv.startup.network) through your localization
Character, Alliance, Campaign, ShopProjectV*ErrorSafeMessage (already safe for players)
Gameplay dataProjectVGameplayDataResultSafeMessage; keep ErrorCode for logs

All error types expose Category (ProjectVBackendErrorCategory), Code and, where the server returned one, RequestId for support.