Typing

class rx.core.typing.Disposable

Disposable abstract base class.

abstract dispose()

Dispose the object: stop whatever we’re doing and release all of the resources we might be using.

Return type

None

class rx.core.typing.Scheduler

Scheduler abstract base class.

abstract property now

Represents a notion of time for this scheduler. Tasks being scheduled on a scheduler will adhere to the time denoted by this property.

Return type

datetime

Returns

The scheduler’s current time, as a datetime instance.

abstract schedule(action, state=None)

Schedules an action to be executed.

Parameters
  • action (Callable[[Scheduler, Optional[~TState]], Optional[Disposable]]) – Action to be executed.

  • state (Optional[~TState]) – [Optional] state to be given to the action function.

Return type

Disposable

Returns

The disposable object used to cancel the scheduled action (best effort).

abstract schedule_relative(duetime, action, state=None)

Schedules an action to be executed after duetime.

Parameters
  • duetime (Union[timedelta, float]) – Relative time after which to execute the action.

  • action (Callable[[Scheduler, Optional[~TState]], Optional[Disposable]]) – Action to be executed.

  • state (Optional[~TState]) – [Optional] state to be given to the action function.

Return type

Disposable

Returns

The disposable object used to cancel the scheduled action (best effort).

abstract schedule_absolute(duetime, action, state=None)

Schedules an action to be executed at duetime.

Parameters
  • duetime (Union[datetime, float]) – Absolute time at which to execute the action.

  • action (Callable[[Scheduler, Optional[~TState]], Optional[Disposable]]) – Action to be executed.

  • state (Optional[~TState]) – [Optional] state to be given to the action function.

Return type

Disposable

Returns

The disposable object used to cancel the scheduled action (best effort).

abstract classmethod to_seconds(value)

Converts time value to seconds. This method handles both absolute (datetime) and relative (timedelta) values. If the argument is already a float, it is simply returned unchanged.

Parameters

value (Union[datetime, timedelta, float]) – the time value to convert to seconds.

Return type

float

Returns

The value converted to seconds.

abstract classmethod to_datetime(value)

Converts time value to datetime. This method handles both absolute (float) and relative (timedelta) values. If the argument is already a datetime, it is simply returned unchanged.

Parameters

value (Union[datetime, timedelta, float]) – the time value to convert to datetime.

Return type

datetime

Returns

The value converted to datetime.

abstract classmethod to_timedelta(value)

Converts time value to timedelta. This method handles both absolute (datetime) and relative (float) values. If the argument is already a timedelta, it is simply returned unchanged. If the argument is an absolute time, the result value will be the timedelta since the epoch, January 1st, 1970, 00:00:00.

Parameters

value (Union[datetime, timedelta, float]) – the time value to convert to timedelta.

Return type

timedelta

Returns

The value converted to timedelta.

class rx.core.typing.PeriodicScheduler

PeriodicScheduler abstract base class.

abstract schedule_periodic(period, action, state=None)

Schedules a periodic piece of work.

Parameters
  • period (Union[timedelta, float]) – Period in seconds or timedelta for running the work periodically.

  • action (Callable[[Optional[~TState]], Optional[~TState]]) – Action to be executed.

  • state (Optional[~TState]) – [Optional] Initial state passed to the action upon the first iteration.

Return type

Disposable

Returns

The disposable object used to cancel the scheduled recurring action (best effort).

class rx.core.typing.Observer(*args, **kwds)

Observer abstract base class

An Observer is the entity that receives all emissions of a subscribed Observable.

abstract on_next(value)

Notifies the observer of a new element in the sequence.

Parameters

value (-T_in) – The received element.

Return type

None

abstract on_error(error)

Notifies the observer that an exception has occurred.

Parameters

error (Exception) – The error that has occurred.

Return type

None

abstract on_completed()

Notifies the observer of the end of the sequence.

Return type

None

class rx.core.typing.Observable(*args, **kwds)

Observable abstract base class.

Represents a push-style collection.

abstract subscribe(observer=None, *, scheduler=None)

Subscribe an observer to the observable sequence.

Parameters
  • observer (Optional[Observer[+T_out]]) – [Optional] The object that is to receive notifications.

  • scheduler (Optional[Scheduler]) – [Optional] The default scheduler to use for this subscription.

Return type

Disposable

Returns

Disposable object representing an observer’s subscription to the observable sequence.

class rx.core.typing.Subject(*args, **kwds)

Subject abstract base class.

Represents an object that is both an observable sequence as well as an observer.

abstract subscribe(observer=None, *, scheduler=None)

Subscribe an observer to the observable sequence.

Parameters
  • observer (Optional[Observer[+T_out]]) – [Optional] The object that is to receive notifications.

  • scheduler (Optional[Scheduler]) – [Optional] The default scheduler to use for this subscription.

Return type

Disposable

Returns

Disposable object representing an observer’s subscription to the observable sequence.

abstract on_next(value)

Notifies the observer of a new element in the sequence.

Parameters

value (-T_in) – The received element.

Return type

None

abstract on_error(error)

Notifies the observer that an exception has occurred.

Parameters

error (Exception) – The error that has occurred.

Return type

None

abstract on_completed()

Notifies the observer of the end of the sequence.

Return type

None