Skip to content

Scheduler delays runnable when added outside component lifecycle #1953

@intendednull

Description

@intendednull

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions