我有以下代码:
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));
我似乎无法弄清楚 [SOMETHING] 需要是什么,我不想等待 ModelAdded 完成,我只是希望它们都为每个事件发出 (m)。
放轻松,我是 Rx 新手