rxpy observablesobservers and subjects observers in rxpy we can add an observer to an observable using the subcribe(method this method can be supplied with lambda functiona named function or an object whose class implements the observer protocol for examplethe simplest way to create an observer is to use lambda functionsubscribe lambda function observable subscribe(lambda valueprint('lambda received'value)when the observable publishes data the lambda function will be invoked each data item published will be supplied independently to the function the output from the above subscription for the previous observable islambda received lambda received lambda received lambda received we can also have used standard or named function as an observerdef prime_number_reporter(value)print('function received'valuesubscribe named function observable subscribe(prime_number_reporternote that it is only the name of the function that is used with the subscribe(method (as this effectively passes reference to the function into the methodif we now run this code using the previous observable we getfunction received function received function received function received in actual fact the subscribe(method takes four optional parameters thes areon_next action to invoke for each data item generated by the observable on_error action to invoke upon exceptional termination of the observable sequence on_completed action to invoke upon graceful termination of the observable sequence observer the object that is to receive notifications you may subscribe using an observer or callbacksnot both