private IObservable <TimeSpan> StartOnSubscription() { // Null identifies very fist subscription. // internal enable/disabled is done with _disabledClock to differentiate // between first/connection, any subsequent connections. if (_dataClockConnection == null) { _dataClockConnection = _dataClockSource.Connect(); } return(_dataClockSource.AsObservable()); }
public async Task <IObservable <BusinessData <TBusinessData> > > CreateObservable(CancellationToken cancellationToken = default) { this.cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); this.deletetionTask = Task.Run(() => this.DeleteOldSnapshots( maxAge: TimeSpan.FromDays(1), sleepTime: TimeSpan.FromMinutes(1), cancellationToken: this.cts.Token)); var updateFunc = this.applyUpdate.ToFSharpFunc(); FSharpResult <BusinessData <TBusinessData>, BusinessDataUpdateError> snapshotResult = await this.FetchBusinessDataSnapshot(this.cts.Token); if (snapshotResult.IsError) { return(Observable.Throw <BusinessData <TBusinessData> >(((BusinessDataUpdateError.SnapshotDownloadError)snapshotResult.ErrorValue).Item)); } var snapshot = snapshotResult.ResultValue; IConnectableObservable <BusinessData <TBusinessData> > connectableObservable = this.updateMessagingClient .CreateWatermarkObervable( startingPosition: SeekPosition.NewFromWatermark( snapshot.Watermark.Add(1)), cancellationToken: this.cts.Token) .Scan( seed: snapshotResult, accumulator: (businessData, updateMessage) => updateBusinessData(updateFunc, businessData, updateMessage)) // .Where(d => d.IsOk) .Select(d => d.ResultValue) .StartWith(snapshot) .Publish(initialValue: snapshot); _ = connectableObservable.Connect(); return(connectableObservable.AsObservable()); }
public IObservable <TimeSpan> PlayerClockObservable() { return(_playerClockConnectable.AsObservable()); }
public IObservable <IList <Timestamped <Entity> > > GetStream() { return(_stream.AsObservable()); }
public IObservable <IProfile> ProfileActivated() { return(_profileActivated.AsObservable()); }
public static IObservable <AppDomain> ExecuteOnce(this AppDomain appDomain) => AppdomainOneEmmision.AsObservable();