All Projects → reactiveui → Fusillade

reactiveui / Fusillade

Licence: mit
An opinionated HTTP library for Mobile Development

Projects that are alternatives of or similar to Fusillade

Punchclock
Make sure your asynchronous operations show up to work on time
Stars: ✭ 235 (-12.64%)
Mutual labels:  http-client, cross-platform, dotnet-core, xamarin
Open Source Xamarin Apps
📱 Collaborative List of Open Source Xamarin Apps
Stars: ✭ 318 (+18.22%)
Mutual labels:  cross-platform, xamarin, mobile
Realm Dotnet
Realm is a mobile database: a replacement for SQLite & ORMs
Stars: ✭ 927 (+244.61%)
Mutual labels:  dotnet-core, xamarin, mobile
Brainpowerapp
A visual memory training game, a mobile game made with Xamarin for both Android and IOS .
Stars: ✭ 17 (-93.68%)
Mutual labels:  cross-platform, xamarin, mobile
Uno.quickstart
An Uno "Hello world!" project using Windows UWP, iOS, Android and WebAssembly
Stars: ✭ 157 (-41.64%)
Mutual labels:  cross-platform, xamarin
Uiwidgets
UIWidget is a Unity Package which helps developers to create, debug and deploy efficient, cross-platform Apps.
Stars: ✭ 1,901 (+606.69%)
Mutual labels:  cross-platform, mobile
Netcorecms
NetCoreCMS is a modular theme supported Content Management System developed using ASP.Net Core 2.0 MVC. Which is also usable as web application framework. This project is still under development. Please do not use before it's first release.
Stars: ✭ 165 (-38.66%)
Mutual labels:  cross-platform, dotnet-core
Skiasharp
SkiaSharp is a cross-platform 2D graphics API for .NET platforms based on Google's Skia Graphics Library. It provides a comprehensive 2D API that can be used across mobile, server and desktop models to render images.
Stars: ✭ 2,493 (+826.77%)
Mutual labels:  cross-platform, xamarin
Easy.logger
A modern, high performance cross platform wrapper for Log4Net.
Stars: ✭ 118 (-56.13%)
Mutual labels:  cross-platform, dotnet-core
Coverlet
Cross platform code coverage for .NET
Stars: ✭ 2,303 (+756.13%)
Mutual labels:  cross-platform, dotnet-core
Youi
Next generation user interface and application development in Scala and Scala.js for web, mobile, and desktop.
Stars: ✭ 186 (-30.86%)
Mutual labels:  cross-platform, mobile
Protobuild
This project has been retired.
Stars: ✭ 153 (-43.12%)
Mutual labels:  cross-platform, xamarin
Flutter app sample
flutter app sample
Stars: ✭ 120 (-55.39%)
Mutual labels:  cross-platform, mobile
Framework
The Aurelia 1 framework entry point, bringing together all the required sub-modules of Aurelia.
Stars: ✭ 11,672 (+4239.03%)
Mutual labels:  cross-platform, mobile
Hello imgui
Hello, Dear ImGui: cross-platform Gui apps for Windows / Mac / Linux / iOS / Android / Emscripten with the simplicity of a "Hello World" app
Stars: ✭ 120 (-55.39%)
Mutual labels:  cross-platform, mobile
Akavache
An asynchronous, persistent key-value store created for writing desktop and mobile applications, based on SQLite3. Akavache is great for both storing important data as well as cached local data that expires.
Stars: ✭ 2,185 (+712.27%)
Mutual labels:  cross-platform, xamarin
Titanium mobile
🚀 Native iOS- and Android- Apps with JavaScript
Stars: ✭ 2,553 (+849.07%)
Mutual labels:  cross-platform, mobile
Jaya
Cross platform file manager application for Windows, Mac and Linux operating systems. (planned mobile support)
Stars: ✭ 219 (-18.59%)
Mutual labels:  cross-platform, dotnet-core
Poco
The POCO C++ Libraries are powerful cross-platform C++ libraries for building network- and internet-based applications that run on desktop, server, mobile, IoT, and embedded systems.
Stars: ✭ 5,762 (+2042.01%)
Mutual labels:  http-client, cross-platform
Expressive
Expressive is a cross-platform expression parsing and evaluation framework. The cross-platform nature is achieved through compiling for .NET Standard so it will run on practically any platform.
Stars: ✭ 113 (-57.99%)
Mutual labels:  cross-platform, xamarin

NuGet Stats Build Code Coverage


Fusillade: An opinionated HTTP library for Mobile Development

Fusillade helps you to write more efficient code in mobile and desktop applications written in C#. Its design goals and feature set are inspired by Volley as well as Picasso.

What even does this do for me?

Fusillade is a set of HttpMessageHandlers (i.e. "drivers" for HttpClient) that make your mobile applications more efficient and responsive:

  • Auto-deduplication of relevant requests - if every instance of your TweetView class requests the same avatar image, Fusillade will only do one request and give the result to every instance. All GET, HEAD, and OPTIONS requests are deduplicated.

  • Request Limiting - Requests are always dispatched 4 at a time (the Volley default) - issue lots of requests without overwhelming the network connection.

  • Request Prioritization - background requests should run at a lower priority than requests initiated by the user, but actually implementing this is quite difficult. With a few changes to your app, you can hint to Fusillade which requests should skip to the front of the queue.

  • Speculative requests - On page load, many apps will try to speculatively cache data (i.e. try to pre-download data that the user might click on). Marking requests as speculative will allow requests until a certain data limit is reached, then cancel future requests (i.e. "Keep downloading data in the background until we've got 5MB of cached data")

How do I use it?

The easiest way to interact with Fusillade is via a class called NetCache, which has a number of built-in scenarios:

public static class NetCache
{
    // 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
    public static HttpMessageHandler Speculative { get; set; }

    // Use for network requests that are running in the background
    public static HttpMessageHandler Background { get; set; }

    // Use for network requests that are fetching data that the user is
    // waiting on *right now*
    public static HttpMessageHandler UserInitiated { get; set; }
}

To use them, just create an HttpClient with the given handler:

var client = new HttpClient(NetCache.UserInitiated);
var response = await client.GetAsync("http://httpbin.org/get");
var str = await response.Content.ReadAsStringAsync();

Console.WriteLine(str);

Where does it work?

Everywhere! Fusillade is a Portable Library, it works on:

  • Xamarin.Android
  • Xamarin.iOS
  • Xamarin.Mac
  • Windows Desktop apps
  • WinRT / Windows Phone 8.1 apps
  • Windows Phone 8

More on speculative requests

Generally, on a mobile app, you'll want to reset the Speculative limit every time the app resumes from standby. How you do this depends on the platform, but in that callback, you need to call:

NetCache.Speculative.ResetLimit(1048576 * 5/*MB*/);

Offline Support

Fusillade can optionally cache responses that it sees, then play them back to you when your app is offline (or you just want to speed up your app by fetching cached data). Here's how to set it up:

  • Implement the IRequestCache interface:
public interface IRequestCache
{
    /// <summary>
    /// Implement this method by saving the Body of the response. The
    /// response is already downloaded as a ByteArrayContent so you don't
    /// have to worry about consuming the stream.
    /// <param name="request">The originating request.</param>
    /// <param name="response">The response whose body you should save.</param>
    /// <param name="key">A unique key used to identify the request details.</param>
    /// <param name="ct">Cancellation token.</param>
    /// <returns>Completion.</returns>
    Task Save(HttpRequestMessage request, HttpResponseMessage response, string key, CancellationToken ct);

    /// <summary>
    /// Implement this by loading the Body of the given request / key.
    /// </summary>
    /// <param name="request">The originating request.</param>
    /// <param name="key">A unique key used to identify the request details,
    /// that was given in Save().</param>
    /// <param name="ct">Cancellation token.</param>
    /// <returns>The Body of the given request, or null if the search
    /// completed successfully but the response was not found.</returns>
    Task<byte[]> Fetch(HttpRequestMessage request, string key, CancellationToken ct);
}
  • Set an instance to NetCache.RequestCache, and make some requests:
NetCache.RequestCache = new MyCoolCache();

var client = new HttpClient(NetCache.UserInitiated);
await client.GetStringAsync("https://httpbin.org/get");
  • Now you can use NetCache.Offline to get data even when the Internet is disconnected:
// This will never actually make an HTTP request, it will either succeed via
// reading from MyCoolCache, or return an HttpResponseMessage with a 503 Status code.
var client = new HttpClient(NetCache.Offline);
await client.GetStringAsync("https://httpbin.org/get");

How do I use this with ModernHttpClient?

Add this line to a static constructor of your app's startup class:

using Splat;

Locator.CurrentMutable.RegisterConstant(new NativeMessageHandler(), typeof(HttpMessageHandler));

What do the priorities mean?

The precedence is UserInitiated > Background > Speculative Which means that anything set as UserInitiate has a higher priority than Background or Speculative.

Explicit is a special that allows to set an explicit value that can be higher, lower or in between any of the predefined cases.

var lowerThanSpeculative = new RateLimitedHttpMessageHandler(
                new HttpClientHandler(), 
                Priority.Explicit, 
                9);

var moreThanSpeculativeButLessThanBAckground = new RateLimitedHttpMessageHandler(
                new HttpClientHandler(), 
                Priority.Explicit, 
                15);

var doItBeforeEverythingElse = new RateLimitedHttpMessageHandler(
                new HttpClientHandler(), 
                Priority.Explicit, 
                1000);

Statics? That sucks! I like $OTHER_THING! Your priorities suck, I want to come up with my own scheme!

NetCache is just a nice pre-canned default, the interesting code is in a class called RateLimitedHttpMessageHandler. You can create it explicitly and configure it as-needed.

What's with the name?

The word 'Fusillade' is a synonym for Volley :)

Contribute

Fusillade is developed under an OSI-approved open source license, making it freely usable and distributable, even for commercial use. Because of our Open Collective model for funding and transparency, we are able to funnel support and funds through to our contributors and community. We ❤ the people who are involved in this project, and we’d love to have you on board, especially if you are just getting started or have never contributed to open-source before.

So here's to you, lovely person who wants to join us — this is how you can support us:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].