第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何從 Action<T> 創(chuàng)建 Observable?

如何從 Action<T> 創(chuàng)建 Observable?

PHP
蠱毒傳說 2024-01-20 15:58:00
我試圖從一個(gè) Action 創(chuàng)建一個(gè) Observable,但是 andFromEventPattern語法FromEvent讓我很難理解。這是我的嘗試:Observable    .FromEventPattern<Action<IStreamTrade>, IStreamTrade>(        x => _polygonSocket.TradeReceived += x,        x => _polygonSocket.TradeReceived -= x)    .Select(x => x?.EventArgs)    .IsNotNull()    .Subscribe( /** do stuff **/)    .DisposeWith(Bindings);我覺得FromEventPattern這里可能不是正確的選擇,但我無法編譯其他任何內(nèi)容。會(huì)發(fā)生什么:我收到一個(gè)Parameter count mismatch.異常,如下所示:Parameter count mismatch.Thread started:  #26  at System.Delegate.CreateDelegate (System.Type type, System.Object firstArgument, System.Reflection.MethodInfo method, System.Boolean throwOnBindFailure, System.Boolean allowClosed) [0x000ee] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/mcs/class/corlib/System/Delegate.cs:230   at System.Delegate.CreateDelegate (System.Type type, System.Object firstArgument, System.Reflection.MethodInfo method) [0x00000] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/mcs/class/corlib/System/Delegate.cs:296   at System.Reactive.ReflectionUtils.CreateDelegate[TDelegate] (System.Object o, System.Reflection.MethodInfo method) [0x00000] in <370f6a6bb34048878534065376a195cb>:0   at System.Reactive.Linq.ObservableImpl.FromEventPattern+Impl`2[TDelegate,TEventArgs].GetHandler (System.Action`1[T] onNext) [0x0003d] in <370f6a6bb34048878534065376a195cb>:0   at System.Reactive.Linq.ObservableImpl.EventProducer`2+Session[TDelegate,TArgs].Initialize () [0x00023] in <370f6a6bb34048878534065376a195cb>:0   at System.Reactive.Linq.ObservableImpl.EventProducer`2+Session[TDelegate,TArgs].Connect (System.IObserver`1[T] observer) [0x00033] in <370f6a6bb34048878534065376a195cb>:0 我正在尋找什么:我想學(xué)習(xí)如何從Action<IStreamTrade>. 我對(duì)使用的解決方案持開放態(tài)度Observable.Create,但更喜歡使用FromEvent或的解決方案FromEventPattern(如果可能的話)。GitHub 源代碼
查看完整描述

2 回答

?
ITMISS

TA貢獻(xiàn)1871條經(jīng)驗(yàn) 獲得超8個(gè)贊

嘗試使用Observable.FromEvent,它將通用的基于 Action 的 .NET 事件轉(zhuǎn)換為可觀察的序列:


Observable.FromEvent<IStreamTrade>(

    x => _polygonSocket.TradeReceived += x,

    x => _polygonSocket.TradeReceived -= x)

.Subscribe( /** do stuff **/)

.DisposeWith(Bindings);


查看完整回答
反對(duì) 回復(fù) 2024-01-20
?
繁星coding

TA貢獻(xiàn)1797條經(jīng)驗(yàn) 獲得超4個(gè)贊

雖然我更喜歡,并使用了維塔利的方法。這是使用的另一種方法Observable.Create。


Observable

    .Create<IStreamTrade>(

    x =>

    {

        Action<IStreamTrade> aist = st => x.OnNext(st);

        _polygonSocket.TradeReceived += aist;

        return Disposable.Create(() => _polygonSocket.TradeReceived -= aist);

    })

    .Subscribe()

    .DisposeWith(Bindings);


查看完整回答
反對(duì) 回復(fù) 2024-01-20
  • 2 回答
  • 0 關(guān)注
  • 190 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)