Chuyển tới nội dung chính

ProjectVUiSubscriptions class

Subscribes UI to the sign-in, startup and header presenters, and logs when each update has been applied by your callback. Use these instead of SubscribeAsync for UI code. The log entry marks your callback returning, not the frame being drawn or the server finishing.

Namespace: SilverTiger.ProjectV.Unity.Presentation

public static class ProjectVUiSubscriptions

Methods​

SubscribeUiAsync(IProjectVAuthenticationPresenter presenter, ProjectVUiBindingId bindingId, Action<ProjectVAuthenticationSnapshot> apply, CancellationToken cancellationToken)​

Calls apply right away with the current sign-in snapshot, then with each newer one. Your callback runs on the thread that delivers the update; this method does not switch threads.

public static Task<IDisposable> SubscribeUiAsync(this IProjectVAuthenticationPresenter presenter, ProjectVUiBindingId bindingId, Action<ProjectVAuthenticationSnapshot> apply, CancellationToken cancellationToken = default);

Parameters

NameTypeDescription
presenterIProjectVAuthenticationPresenterThe presenter to observe.
bindingIdProjectVUiBindingIdMust be ProjectVUiBindingId.LoginAuthentication.
applyAction<ProjectVAuthenticationSnapshot>Updates your UI from a snapshot.
cancellationTokenCancellationTokenStops logging for this subscription once cancelled; it does not end the subscription.

Returns

Task<IDisposable>: A subscription; dispose it to stop receiving updates.

Exceptions

ExceptionWhen
ArgumentNullExceptionpresenter or apply is null.
ArgumentOutOfRangeExceptionbindingId is not ProjectVUiBindingId.LoginAuthentication.

SubscribeUiAsync(IProjectVStartupPresenter presenter, ProjectVUiBindingId bindingId, Action<ProjectVStartupSnapshot> apply, CancellationToken cancellationToken)​

Calls apply right away with the current startup snapshot, then with each newer one. Your callback runs on the thread that delivers the update; this method does not switch threads.

public static Task<IDisposable> SubscribeUiAsync(this IProjectVStartupPresenter presenter, ProjectVUiBindingId bindingId, Action<ProjectVStartupSnapshot> apply, CancellationToken cancellationToken = default);

Parameters

NameTypeDescription
presenterIProjectVStartupPresenterThe presenter to observe.
bindingIdProjectVUiBindingIdMust be ProjectVUiBindingId.LoginStartup.
applyAction<ProjectVStartupSnapshot>Updates your UI from a snapshot.
cancellationTokenCancellationTokenStops logging for this subscription once cancelled; it does not end the subscription.

Returns

Task<IDisposable>: A subscription; dispose it to stop receiving updates.

Exceptions

ExceptionWhen
ArgumentNullExceptionpresenter or apply is null.
ArgumentOutOfRangeExceptionbindingId is not ProjectVUiBindingId.LoginStartup.

SubscribeUiAsync(IProjectVHeaderPresenter presenter, ProjectVUiBindingId bindingId, Action<ProjectVHeaderSnapshot> apply, CancellationToken cancellationToken)​

Calls apply right away with the current header snapshot, then with each newer one. Your callback runs on the thread that delivers the update; this method does not switch threads.

public static Task<IDisposable> SubscribeUiAsync(this IProjectVHeaderPresenter presenter, ProjectVUiBindingId bindingId, Action<ProjectVHeaderSnapshot> apply, CancellationToken cancellationToken = default);

Parameters

NameTypeDescription
presenterIProjectVHeaderPresenterThe presenter to observe.
bindingIdProjectVUiBindingIdMust be ProjectVUiBindingId.Header.
applyAction<ProjectVHeaderSnapshot>Updates your UI from a snapshot.
cancellationTokenCancellationTokenStops logging for this subscription once cancelled; it does not end the subscription.

Returns

Task<IDisposable>: A subscription; dispose it to stop receiving updates.

Exceptions

ExceptionWhen
ArgumentNullExceptionpresenter or apply is null.
ArgumentOutOfRangeExceptionbindingId is not ProjectVUiBindingId.Header.