Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scheduler delays runnable when added outside component lifecycle #1953

Closed
1 of 3 tasks
intendednull opened this issue Jul 16, 2021 · 0 comments · Fixed by #1954
Closed
1 of 3 tasks

Scheduler delays runnable when added outside component lifecycle #1953

intendednull opened this issue Jul 16, 2021 · 0 comments · Fixed by #1954
Labels

Comments

@intendednull
Copy link
Contributor

intendednull commented Jul 16, 2021

Problem

#1903 introduced a bug that caused messages sent to an agent outside a component's lifecycle to be delayed until a component lifecycle event is triggered.

Yewdux uses an agent bridge for generating flexible callbacks. If a message is sent immediately inside a component's lifecycle, it is executed as expected:

        self.bridge()
            .borrow_mut()
            .send_service(ServiceRequest::ApplyOnce(Box::new(f)))

However when a message is sent from a inside a callback it will not be executed.

        let bridge = Rc::clone(self.bridge());
        let f = Rc::new(f);
        Callback::from(move |_| {
            bridge
                .borrow_mut()
                .send_service(ServiceRequest::Apply(f.clone()))
        })

Only when a component lifecycle event is triggered will the bridge message then be executed.

Expected behavior
Bridge messages should be executed normally when sent from a callback.

Environment:

  • Yew version: master
  • Rust version: nightly

Questionnaire

  • I'm interested in fixing this myself but don't know where to start
  • I would like to fix and I have a solution
  • I don't have time to fix this right now, but maybe later
@intendednull intendednull changed the title Scheduler doesn't execute main queue outside component lifecycle Scheduler delays runnable when added outside component lifecycle Jul 16, 2021
intendednull added a commit to intendednull/yew that referenced this issue Jul 16, 2021
Fixes an issue where a runnable added from outside the component
lifecyle (i.e. agent bridge message from inside a callback) would not be
executed until the next component lifecycle event.
siku2 pushed a commit that referenced this issue Jul 16, 2021
* Fix scheduler main queue delay (#1953)

Fixes an issue where a runnable added from outside the component
lifecyle (i.e. agent bridge message from inside a callback) would not be
executed until the next component lifecycle event.

* Add test for `scheduler::run`

Ensures `scheduler::run` executes runnables immediately.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant