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

crate feature tokio fails to build #732

Closed
anishsinha-io opened this issue Jan 12, 2025 · 0 comments · Fixed by #733
Closed

crate feature tokio fails to build #732

anishsinha-io opened this issue Jan 12, 2025 · 0 comments · Fixed by #733

Comments

@anishsinha-io
Copy link
Contributor

anishsinha-io commented Jan 12, 2025

Building floem with crate feature tokio on (at least) the last three commits of main fail with the following error (tested with the example in the GitHub readme):

error[E0308]: mismatched types
   --> /Users/anishsinha/.cargo/git/checkouts/floem-69eea0a757d1e3ee/5ab32a2/src/ext_event.rs:232:52
    |
232 |             crate::ext_event::register_ext_trigger(trigger);
    |             -------------------------------------- ^^^^^^^ expected `ExtSendTrigger`, found `Trigger`
    |             |
    |             arguments to this function are incorrect
    |
note: function defined here
   --> /Users/anishsinha/.cargo/git/checkouts/floem-69eea0a757d1e3ee/5ab32a2/src/ext_event.rs:85:8
    |
85  | pub fn register_ext_trigger(trigger: ExtSendTrigger) {
    |        ^^^^^^^^^^^^^^^^^^^^ -----------------------

For more information about this error, try `rustc --explain E0308`.
error: could not compile `floem` (lib) due to 1 previous error

Steps to reproduce

Paste the following in your main.rs

use floem::prelude::*;

fn main() {
    floem::launch(counter_view);
}

fn counter_view() -> impl IntoView {
    let mut counter = RwSignal::new(0);

    h_stack((
        button("Increment").action(move || counter += 1),
        label(move || format!("Value: {counter}")),
        button("Decrement").action(move || counter -= 1),
    ))
    .style(|s| s.size_full().items_center().justify_center().gap(10))
}

Put the following in your Cargo.toml

floem = { git = "https://github.com/lapce/floem.git", features = ["tokio"] }

It's worth noting that this issue is NOT present in the latest release version (0.2.0), so if you use version 0.2.0 the build will succeed. I don't know when exactly this regressed, however, I tested with the last few commits on main.

Next steps

It didn't look like too difficult of a fix so I attempted to patch it. If you run the example with the following dependency:

floem = { git = "https://github.com/anishsinha-io/floem.git", features = [
  "tokio",
], branch = "fix-signal-from-tokio-channel" }

then the build will succeed. At least, it did for me on a m1 max macbook. I'll make a PR for you all to review soon.

@jrmoulton jrmoulton linked a pull request Jan 14, 2025 that will close this issue
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 a pull request may close this issue.

1 participant