Skip to content

Instantly share code, notes, and snippets.

@grokys
Last active June 14, 2016 11:31
Show Gist options
  • Select an option

  • Save grokys/7e59a2f3cb3b36638c1835936dbc526b to your computer and use it in GitHub Desktop.

Select an option

Save grokys/7e59a2f3cb3b36638c1835936dbc526b to your computer and use it in GitHub Desktop.

The UIProvider

The UIProvider is used to initiate new UI flows, for example showing the login dialog. To get an instance of UIProvider to work with, import the IUIProvider service in your constructor:

[ImportingConstructor]
public ExampleViewModel(IUIProvider uiProvider)
{
    this.uiProvider = uiProvider;
}

To initiate a UI flow, call SetupUI with the desired UIControllerFlow, passing in an IConnection if the flow is not the login flow:

// Here we're starting the login flow (Authentication) so we pass null as the
// connection.
var transition = uiProvider.SetupUI(UIControllerFlow.Authentication, null)

To run the flow, call RunUI:

uiProvider.RunUI();

The SetupUI method returned an observable which tracks the current state of the UI flow and will complete when the flow is complete, either because the flow progressed to completion or because the user cancelled the operation:

transition.Subscribe(
  _ => { /* Called with the current flow state */ },
  () => { /* Called when the flow completes */ });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment