port from perforce
This commit is contained in:
32
intromat/Intromat/AkavacheSuspensionDriver.cs
Normal file
32
intromat/Intromat/AkavacheSuspensionDriver.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Reactive;
|
||||
using Akavache;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Intromat
|
||||
{
|
||||
public class AkavacheSuspensionDriver<TAppState> : ISuspensionDriver where TAppState : class
|
||||
{
|
||||
private const string AppStateKey = "appState";
|
||||
|
||||
public AkavacheSuspensionDriver()
|
||||
{
|
||||
BlobCache.ApplicationName = "Your Application Name";
|
||||
}
|
||||
|
||||
public IObservable<Unit> InvalidateState()
|
||||
{
|
||||
return BlobCache.UserAccount.InvalidateObject<TAppState>(AppStateKey);
|
||||
}
|
||||
|
||||
public IObservable<object> LoadState()
|
||||
{
|
||||
return BlobCache.UserAccount.GetObject<TAppState>(AppStateKey)!;
|
||||
}
|
||||
|
||||
public IObservable<Unit> SaveState(object state)
|
||||
{
|
||||
return BlobCache.UserAccount.InsertObject(AppStateKey, (TAppState)state);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user