Skip to content

Instantly share code, notes, and snippets.

View rdelrosario's full-sized avatar

Rendy Del Rosario rdelrosario

View GitHub Profile
public enum VideoState
{
Idle,
Playing,
Paused,
Stopped
}
public partial class App : Application
{
public App()
{
InitializeComponent();
RxApp.DefaultExceptionHandler = new RxExceptionHandler();
Instance.InitializeForms();
namespace ReactiveToDoSample
{
public class NavigationParameterConstants
{
public const string ItemId = "ItemId";
}
}
namespace ReactiveToDoSample.ViewModels
{
public class ItemViewModel : ViewModelBase
{
public ItemViewModel(IParameterViewStackService navigationService, IItemManager itemManager) : base(navigationService)
{
_itemManager = itemManager;
var canExecute = this.WhenAnyValue(x => x.Title, (title) => !string.IsNullOrEmpty(title));
<?xml version="1.0" encoding="UTF-8" ?>
<rxui:ReactiveContentPage
x:Class="ReactiveToDoSample.Views.ItemPage"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:rxui="clr-namespace:ReactiveUI.XamForms;assembly=ReactiveUI.XamForms"
xmlns:vm="clr-namespace:ReactiveToDoSample.ViewModels"
x:TypeArguments="vm:ItemViewModel">
<rxui:ReactiveContentPage.ToolbarItems>
<ToolbarItem Command="{Binding CloseCommand}" Text="Close" />
namespace ReactiveToDoSample.ViewModels
{
public class HomeViewModel : ViewModelBase
{
public HomeViewModel(IParameterViewStackService navigationService, IItemManager itemManager) : base(navigationService)
{
DeleteCommand = ReactiveCommand.Create<Item>(itemManager.Remove);
itemManager
.ItemChanges
<?xml version="1.0" encoding="UTF-8" ?>
<rxui:ReactiveContentPage
x:Class="ReactiveToDoSample.Views.HomePage"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:rxui="clr-namespace:ReactiveUI.XamForms;assembly=ReactiveUI.XamForms"
xmlns:vm="clr-namespace:ReactiveToDoSample.ViewModels"
x:Name="homePage"
Title="Reactive ToDo"
x:TypeArguments="vm:HomeViewModel">
public class ItemManager : IItemManager
{
public ItemManager()
{
ItemChanges = _itemsCache.Connect()
.RefCount();
}
public Optional<Item> Get(string id) => _itemsCache.Lookup(id);
namespace ReactiveToDoSample.Managers
{
public interface IItemManager
{
public IObservable<IChangeSet<Item, string>> ItemChanges { get; }
public Optional<Item> Get(string id);
public void AddOrUpdate(Item item);
namespace ReactiveToDoSample.Models
{
public class Item : ReactiveObject
{
public Item(string id, string title)
{
Id = id;
Title = title;
}