Skip to content

Conversation

philippjfr
Copy link
Member

We already support using asynchronous and generator functions as inputs to a reactive expression but until now we did not handle them when you use them as an input to an operation that is performed on the data. This meant that .rx.pipe and .rx.map would simply return the coroutine or generator as the value instead of evaluating it lazily.

Here we add support for these by scheduling the task on the event loop and then triggering an event when the function evaluates. Internally this is achieved by creating a Trigger which is added as one of the dependencies of the reactive expression such as that any consumer of the expression (whether Panel, the display hook or anything else) is notified when the async function or generator yields a new value.

In testing this I also found an oversight which meant that if you used a bound function as the input to .rx.pipe it would not extract its dependencies.

@philippjfr philippjfr marked this pull request as ready for review March 21, 2024 13:09
@philippjfr philippjfr requested a review from hoxbro March 21, 2024 13:16
Copy link
Member

@hoxbro hoxbro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor comments, but LGTM.

@philippjfr philippjfr merged commit dd8c295 into main Mar 22, 2024
@philippjfr philippjfr deleted the async_pipe branch March 22, 2024 00:14
@philippjfr philippjfr mentioned this pull request Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants