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

Update eframe, add trunk setup #11

Closed

Conversation

AngelOnFira
Copy link

@AngelOnFira AngelOnFira commented Apr 23, 2023

This takes the work started in #9, and updates eframe.

I'm going to start this as a draft PR, since although everything compiles, there are still some areas that I need to fix, and have questions about.

The biggest item is migrating the use of the App trait; previously, the setup function was used to prepare the websocket listener. Some of the logic in this PR might not be feature similar just yet.

This will close #9.

Comment on lines -22 to -25
if let Some(web_info) = &frame.info().web_info {
// allow `?url=` query param
if let Some(url) = web_info.location.query_map.get("url") {
self.url = url.clone();
Copy link
Author

Choose a reason for hiding this comment

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

This previous logic looked into frame to figure out whether we are in a web environment or not. However, with the use of the new() method to instantiate this app, it doesn't seem to have access to the frame information. Because of this, I'm not sure how to go about getting the information from before.

I know update gives us access to the frame, but I don't imagine putting this logic in there to be run every frame would be the best.

How might this logic be migrated the best?

// allow `?url=` query param
if let Some(url) = web_info.location.query_map.get("url") {
self.url = url.clone();
fn connect(&mut self, ctx: Context) {
Copy link
Author

Choose a reason for hiding this comment

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

I've let this function take a moved Context, and everywhere that calls this function clones Context first. Is that the right way to handle passing context? If I just pass a reference, then I run into an issue with lifetimes that I didn't want to explore.

Is Context designed to be cloned?

Comment on lines +50 to +51
#[cfg(not(target_arch = "wasm32"))]
frame.close();
Copy link
Author

Choose a reason for hiding this comment

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

I believe this is the best way to handle the case where we're not in WASM? Maybe it would be better to just have this entire TopBottomPanel be scoped and cfgd?

{
self.connect(frame.clone());
self.connect(ctx.clone());
Copy link
Author

Choose a reason for hiding this comment

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

clone 😎

pub fn start(canvas_id: &str) -> std::result::Result<(), eframe::wasm_bindgen::JsValue> {
pub fn start(canvas_id: &str) {
Copy link
Author

Choose a reason for hiding this comment

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

Another area I'm unsure about. We seem to have two entrypoints for WASM; the one that is added in this commit, and the existing one in lib.rs. Should only one be required?

Also, removing the return type is just to get it to compile. Not sure if this is the right thing to do here just yet.

@duckfromdiscord
Copy link

awesome to see you used my issue & commit :) good luck with the PR!

@Its-Just-Nans
Copy link

Hi

@AngelOnFira is this going to be merged ?

@emilk
Copy link
Member

emilk commented May 21, 2024

This has been in draft for too long. Please try to make your PRs small and focused. If you want to update eframe or add trunk, please do so in separate PRs

@emilk emilk closed this May 21, 2024
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.

you cannot trunk serve the example app out of the box
4 participants