我有以下代码:
Observable.FromEvent<ModelEventArgs>(
h => ValuesController.ModelAdded += h,
h => ValuesController.ModelAdded -= h)
.Subscribe(m => context.Connection.Broadcast(m));
Observable.FromEvent<ModelEventArgs>(
h => ValuesController.ModelDeleted += h,
h => ValuesController.ModelDeleted -= h)
.Subscribe(m => context.Connection.Broadcast(m));
什么将是什么:
Observable.[SOMETHING](
Observable.FromEvent<ModelEventArgs>(
h => ValuesController.ModelAdded += h,
h => ValuesController.ModelAdded -= h),
Observable.FromEvent<ModelEventArgs>(
h => ValuesController.ModelDeleted += h,
h => ValuesController.ModelDeleted -= h))
.Subscribe(m => context.Connection.Broadcast(m));
我似乎无法弄清楚[某物]需要什么,我不想等待ModelAdded完成,我只希望他们俩都在每个事件中散发(M)。
对我轻松,我是RX NewB
我想您正在寻找Merge
:
Observable.Merge(
Observable.FromEvent<ModelEventArgs>(
h => ValuesController.ModelAdded += h,
h => ValuesController.ModelAdded -= h),
Observable.FromEvent<ModelEventArgs>(
h => ValuesController.ModelDeleted += h,
h => ValuesController.ModelDeleted -= h))
.Subscribe(m => context.Connection.Broadcast(m));