private void SetMapDisposable(KanColleProxy proxy) { var mapStart = proxy.api_req_map_start.TryParse <kcsapi_map_start>().Subscribe(x => Create(x.Data)); _CompositDisposable.Add(mapStart); var next = KanColleClient.Current.Proxy.ApiSessionSource.Where (x => x.Request.PathAndQuery == "/kcsapi/api_req_map/next").TryParse <kcsapi_map_start>().Subscribe(x => Update(x.Data)); _CompositDisposable.Add(next); }
public static T AddTo <T>(this T disposable, MultipleDisposable obj) where T : IDisposable { if (obj == null) { disposable.Dispose(); } else { obj.Add(disposable); } return(disposable); }
// Creates a cell of collection from collection of cells. Useful when you need to agrigate collections of dynamic data. public static ICell <IEnumerable <T> > ToCellOfCollection <T>(this IEnumerable <ICell <T> > cells) { Func <IEnumerable <T> > values = () => cells.Select(cell => cell.value); return(new AnonymousCell <IEnumerable <T> >((Action <IEnumerable <T> > reaction) => { var group = new MultipleDisposable(); foreach (var cell in cells) { group.Add(cell.OnChanged(() => { if (group.disposed) { return; } reaction(values()); })); } return group; }, values)); }