Skip to content

Instantly share code, notes, and snippets.

@hamid-shaikh
Created July 14, 2019 08:27
Show Gist options
  • Save hamid-shaikh/24d93419f9b5313685c4dfc40f4b59dc to your computer and use it in GitHub Desktop.
Save hamid-shaikh/24d93419f9b5313685c4dfc40f4b59dc to your computer and use it in GitHub Desktop.
Refit + Prism Forms + Fusillade
public interface IApiService<TInterfaceService>
{
// Use to fetch data into a cache when a page loads. Expect that
// these requests will only get so far then give up and start failing
TInterfaceService Speculative { get; }
// Use for network requests that are fetching data that the user is
// waiting on *right now*
TInterfaceService UserInitiated { get; }
// Use for network requests that are running in the background
TInterfaceService Background { get; }
}
@syahman
Copy link

syahman commented Jul 22, 2020

dear hamid-shaikh, very thankful for your explanation, now i understand how D.I works in Prism. Being searching this method for almost a week.

i would like to add another nuget to my project instead of Refit + Prism Forms + Fusillade, there will be fody.propertychanged,aritchie Acr.UserDialogs,Polly and Plugin.connectivity. hope this will integrate well with prism. maybe need workaround if i need to inject static interface. so far my prism project able to get API data. what's the difference between RegisterSingleton and RegisterInstance ?

/* Services, D.I */
            containerRegistry.RegisterSingleton<IApiService<IAuthenticationService>, ApiService<IAuthenticationService>>();
            containerRegistry.RegisterInstance(typeof(IUserDialogs), UserDialogs.Instance);

@hamid-shaikh
Copy link
Author

hamid-shaikh commented Jul 22, 2020

@syahman
To understand difference better kindly visit Prism documentation (Very good documentation)

Prism Forms Documentation

One suggestion - Use Xamarin.Essential for Connectivity instead of Plugin.Connectivity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment