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

Support for leptos 0.7 #139

Open
Boscop opened this issue Oct 9, 2024 · 4 comments
Open

Support for leptos 0.7 #139

Boscop opened this issue Oct 9, 2024 · 4 comments
Labels
feature New feature or request

Comments

@Boscop
Copy link

Boscop commented Oct 9, 2024

Hey, thanks for making this crate, it seems very useful 🙂

Is there a branch that works with Leptos 0.7 or is it planned? :)

(I'm asking because I'm using Leptos 0.7.)

@phillipbaird
Copy link
Collaborator

Good timing. I was just about to open an issue for this myself.

My fork has a 0.7 branch that's ready for testing.
Happy to create a pull request to the main repo if the project maintainers would like it.

Here's some notes on what has changed:

  • added send_wrapper dependency due to the requirement for signal values to be send
  • used new_local() signals in various places
  • in use_hotkeys_ref() the keydown_closure became a keyup_closure. This was needed because the hotkeys_context.keys_pressed signal was not getting updated till after the closure was fired. This meant is_last_key_match would always return false as keys_pressed did not contain the pressed key.
  • also in use_hotkeys_ref() added storing of the returned RemoveEventHandler in a Rc<RefCell> as it needs to be stored to prevent the event handler being dropped immediately.
  • the examples needed to be fixed in various places because the defined hotkeys accessed signals via get() methods. In the leptos 0.7 this can create an endless loop. Recommend in your hotkey handlers, that you always access signals using the untracked variants of methods.
  • the Callbacks returned from hotkeys_context now seem a little clunky to use, e.g. in examples/demo the only way I could get it to compile was to explicitly call the run method, so toggle_scope("scope_a".to_string()); has become toggle_scope.run("scope_a".to_string());. I kind of think simple methods on HotkeysContext would be simpler than using Callbacks. Would be interested to hear other peoples opinions on this.

@friendlymatthew friendlymatthew added the feature New feature or request label Oct 10, 2024
@friendlymatthew
Copy link
Member

@Boscop thank you for raising this issue! We definitely should support new releases. Welcome aboard 🎉

@phillipbaird that would be awesome 😸. You should have Write access (check inbox?) to this repository. This way, the CI isn't blocking you during development. Happy to resend, if needed.

Here's some notes on what has changed:

All great points, any chance you can split these into separate smaller PRs? Easier to review and allows for more fine-grained discussion.


cc'ing @mondeja for 👀

@phillipbaird
Copy link
Collaborator

@friendlymatthew I do not see how this can be broken into smaller PRs. This is the minimum change in order for the crate to compile and not be broken. Certainly, how I've done things should be reviewed and discussed as there may be better ways to do things. For this reason I'd like to suggest the creation of a branch in the gaucho-labs repo that I can send a PR to. Use this branch as the starting point for 0.7 support and we can iterate from there.

Let me how you'd like me to proceed. Cheers.

@friendlymatthew
Copy link
Member

Yes of course! For future reference, no need to ask to push a PR. Everyone is welcome 😸

Looking forward to the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants