Skip to content

wasm support? #8

Closed
Closed

Description

@zhangzqs

Is it possible to port it to run on the wasm platform?
wasm in browser don't support Instant::now().
If this interface is defined, it will be able to run on the wasm platform
#2 (comment)

Activity

  1. maxwase commented on May 19, 2024

    @maxwase
    Owner

    That's an interesting question, I didn't consider WASM as a platform for this crate, however it seems that it is possible, so why not 😄

    As you have already spotted, there is an issue for an external timer trait, honestly, I don't have good ideas on how to define one straight away, however I didn't think about it much. This issue is kind of the same to the one in embedded_hal crate, they also struggle to define one generic enough trait...

    Could you please share an example on how you would like to use this crate on WASM platform and how you would implement Instant on it if it misses one? That would help to consider needed aspects for the trait.

  2. zhangzqs commented on May 19, 2024

    @zhangzqs
    ContributorAuthor

    That's an interesting question, I didn't consider WASM as a platform for this crate, however it seems that it is possible, so why not 😄

    As you have already spotted, there is an issue for an external timer trait, honestly, I don't have good ideas on how to define one straight away, however I didn't think about it much.

    Could you please share an example on how you would like to use this crate on WASM platform and how you would implement Instant on it if it misses one? That would help to consider needed aspects for the trait.

    Actually, we don't rely on absolute time, we only need to rely on the relative time since the Button was new, so we can actually just use core::time::Duration instead of Instant.

  3. zhangzqs commented on May 19, 2024

    @zhangzqs
    ContributorAuthor

    I tried to file a draft PR to change this, but noticed that the State enum and raw_state function are public, which means some incompatible changes have occurred to the public API.

    https://github.com/maxwase/button-driver/pull/9/files

  4. maxwase commented on May 20, 2024

    @maxwase
    Owner

    It would be great if you could try to implement your use case using #10

  5. zhangzqs commented on Jul 5, 2024

    @zhangzqs
    ContributorAuthor

    Yes, now it works for my use case, and I added an example running on the browser wasm.

    #16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions