-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add binding for setSerialMessageCallback
#327
Add binding for setSerialMessageCallback
#327
Conversation
Relates to #283 |
Thank you so much! I have to play with it and think about it a little bit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reviewed your solution as well as entire task and have to say that I was wrong when suggested "typed storage".
There is should be solution dramatically simpler.
Also in my example all callbacks are "oneshot" and removing immediately after call with store.remove::<F>()
and later entire storage with clean_store
. That's not needed for this case. This is like update callback registering, so we should be able set callback, receive calls multiple times and optionally "unsubscribe".
I've tested it this way:
# Build, install, run:
cargo playdate run -p=playdate-system --example=set-serial-message-callback --features=sys/lang-items,sys/entry-point --device
--no-read
# Then send messages:
pdtool send msg "one" && pdtool read
pdtool send msg "two" && pdtool read
pdtool send msg "three" && pdtool read
# ...
# Output:
# serial_message_callback: one
# PANIC: [api/system/src/storage.rs@24] "missed callback"
I've created PR for your PR ;)
Simple `set_serial_message_callback`
Strange, I'm running into #326 on this branch despite having pulled in the fixes for that issue. |
For some reason I'm still hitting |
@boozook thanks for the PR. I was thinking this should be similar to |
To clarify, when I run I can try again once it's on |
I hope you doing well. Just to be sure that you're using latest version: |
Adds bindings and an example for
playdate->system->setSerialMessageCallback
Please also see https://devforum.play.date/t/feature-request-add-a-userdata-argument-to-setserialmessagecallback/17333
Thanks!