Skip to content

Conversation

@notoriaga
Copy link
Contributor

No description provided.

tabs.status_bar.borrow_mut().handle_baseline_ned(msg);
});

link.register_cb(|msg: Dops| {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could also move these calls to their respective tab's new function and store a link in each tab as well, like the current console. just trying to keep the changes small

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I could see value both ways. Keeping things here makes it easier to see what all needs what in one spot instead of digging through each file. So adding new messages what have you could be easier in the future.

msg_sender: types::MsgSender,
) -> Self {
Self {
main: MainTab::new(shared_state.clone(), client_sender.clone()).into(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With these changes it might be worth renaming this "MainTab" to something more appropriate. That being said I filed a ticket recently to try and rework some of the logic for logging directory which will hit the MainTab quite a bit. So probably could hold off. Still don't know what it should be called though :D

Copy link
Contributor Author

@notoriaga notoriaga Aug 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I was thinking the same thing. Basically what I did to the main tab was break out any of the functionality that reached into sub-tabs and moved that into the shared state. Which ended up being the three csv log files. But yeah not really sure what to call it now. Maybe we could just put everything into shared state? At this point it seems to pretty much just be global state like are we logging, what was the last gps time etc

Copy link
Collaborator

@john-michaelburke john-michaelburke Aug 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats not a bad idea. SharedState is probably at a point where it could be put into its own file. Would reduce the size of types.rs a bit too which is beyond needed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming suggestion: App, AppState or maybe AppContext (instead of SharedState)

Copy link
Collaborator

@john-michaelburke john-michaelburke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really good. I'd say lets fix up these lint/format issues and :shipit:

@@ -1,16 +1,16 @@
use capnp::message::Builder;
use std::collections::HashMap;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this was a mistake?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I think I just reordered the imports std -> third_party -> crate. we're a little bit all over the place with that (not that it particularity matters)

};

struct Tabs<'a, S: types::CapnProtoSender> {
pub main: Mutex<MainTab<S>>,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alas we do have to use a mutex instead of refcell. This is because there are a few places where we move a Link to a separate thread to read + dispatch messages. I think there is probably a way around it but not 100% sure

@notoriaga notoriaga merged commit fce9caf into main Aug 27, 2021
@notoriaga notoriaga deleted the steve/callbacks branch August 27, 2021 19:12
fn test_dispatcher() {
let mut d = Link::new();
let mut c = Counter { count: 0 };
d.register_cb(|obs| c.obs(obs));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super cool to be able to register a callback based on the type of the function parameter!

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 this pull request may close these issues.

4 participants