Cysharp / R3

The new future of dotnet/reactive and UniRx.
MIT License
1.71k stars 70 forks source link

SubscribeOnMainThread usage in Unity #209

Closed zhang-z closed 3 weeks ago

zhang-z commented 1 month ago

I'm new to R3/Rx.NET. Thinking of refactoring my Unity game in this design pattern:

Is Subscribe**OnMainThread** necessary? Am I using R3 in the correct way? Thanks.

Another question for SubscribeOnMainThread, what if an Observable event happens twice between two frames. What is gonna happen in the MainThread? Handler code executed twice in sequence?

TORISOUP commented 1 month ago

The SubscribeOnMainThread is an operator that adjusts when to subscribe to the Observable (register the Observer to the Observable).

Therefore, once the subscribe process is complete and the message is ready to be received, the operator has no further significance, and the operator does not perform any operation in the order in which the messages are issued.