Search Results for

    Show / Hide Table of Contents

    Configuring Connectivity

    Apizr can check network connectivity for you, right before sending any request.

    It will throw an ApizrException with an IOException as InnerException in case of network failure, which you can handle globally by showing a snack bar info or whatever.

    This way, your viewmodels are kept light and clear of it.

    With boolean factory

    You may want to provide just a simple boolean value to check connectivity.

    Here is the right option:

    • Static
    • Extended
    options => options.WithConnectivityHandler(() => YourConnectivityBoolean)
    
    // Boolean factory
    options => options.WithConnectivityHandler(serviceProvider => YourConnectivityBoolean)
    
    // Boolean expression factory
    options => options.WithConnectivityHandler<IYourRegisteredConnectivityService>(service => service.YourConnectivityBoolean)
    

    With Connectivity Handler

    You could also implement the IConnectivityHandler interface:

    public class YourConnectivityHandler : IConnectivityHandler
    {
        public bool IsConnected()
        {
            // Check connectivity here
        }
    }
    

    Then just register it with this option:

    • Static
    • Extended
    // direct configuration
    options => options.WithConnectivityHandler(YourConnectivityHandler)
    
    // OR factory configuration
    options => options.WithConnectivityHandler(() => YourConnectivityHandler)
    
    // direct configuration
    options => options.WithConnectivityHandler(YourConnectivityHandler)
    
    // OR factory configuration
    options => options.WithConnectivityHandler(serviceProvider => YourConnectivityHandler)
    
    // OR closed generic configuration
    options => options.WithConnectivityHandler<YourConnectivityHandler>()
    
    // OR type configuration
    options => options.WithConnectivityHandler(typeof(YourConnectivityHandler))
    
    In This Article
    Back to top Supported by Respawnsive