0

I feel like I might be missing something very obvious here, but anyway...

When using RxPY, is there an equivalent of the C# RX System.Reactive.Unit type for calling the on_next function with no arguments?

from rx import Observable

source = Observable.return_value(???)
source.subscribe(on_next=lambda: print("on_next called"))

If anyone is curious why I might want to do this, it's because I want the start function in the code below to be called without the x argument

def on_start(func):
    def func_wrapper():
        Observable.return("").subscribe(func)
    return func_wrapper

@on_start
def start(x):
    print(x)

start()
MarkNS
  • 3,811
  • 2
  • 43
  • 60

1 Answers1

0

Well, yes, I was missing something obvious. I can just subscribe, receive the value and ignore it with a lambda.

def on_start(func):
    def func_wrapper():
        Observable.return_value("").subscribe(on_next=lambda _: func())
    return func_wrapper

@on_start
def start():
    print("doh")

start()
MarkNS
  • 3,811
  • 2
  • 43
  • 60