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

[docs] Lack of examples makes for confusing times #3255

Closed
JamesYeoman opened this issue Jan 21, 2022 · 5 comments
Closed

[docs] Lack of examples makes for confusing times #3255

JamesYeoman opened this issue Jan 21, 2022 · 5 comments
Assignees
Labels
type: documentation Need to update the API documentation

Comments

@JamesYeoman
Copy link

I just want to create a file dialog within an async tauri command, but the File Dialog Builder is designed with callbacks. As someone who's not a rust god, I don't know the ins and outs of rust, so I'm still wary of making sure I'm appeasing the borrow checker god.

  • Do I need to explicitly borrow the state object from the command in the callback?
  • Is there a way to update state from within a command?
  • Does the command function need to wait for the callback to complete before exiting (given that the dialog function calls std::thread::spawn)

I really like Tauri, but the examples that are provided are very barebones. I'm trying to use Tauri in a personal project, but every time I finish the frontend work for a feature, I have to spend ages battling to figure out how to do what I want in Tauri. Like for example: what's the purpose of stateObj.0 in all the cases where there's tauri managed state in the state example? Why does the commands example use state.inner() when the documentation for that method states that it's typically unnecessary? And where's the state.0 that the state example implied was required?

Here's what I'm currently struggling with
image

Is there any chance of the examples being updated, improved, and api usage being better explained? Or at the very least, is there any chance of a list of existing tauri-based projects being made so that people can refer to those to see how the api is used?

@JamesYeoman JamesYeoman added the type: documentation Need to update the API documentation label Jan 21, 2022
@lucasfernog lucasfernog self-assigned this Jan 23, 2022
@lucasfernog
Copy link
Member

You're right. I'll improve those APIs and examples.

@nothingismagick
Copy link
Member

Just a bit of a heads up as to WHY this happened, and HOW things are changing.

The examples have been, until now, ways for the core team to continuously validate that the system (which has been in heavy flux) continues to work as we expected. We held off on over-documenting things that we knew might change as a result of the external security audit. Now that the audit is almost over, and we are about to release the 1.0, we will get back to writing documentation that meets the expectations that people like yourself in the community need, in order to be able to hit the ground running.

Obviously it can be frustrating, but as a small team of volunteers we have always felt that it was more worth our time to focus on the code. Thankfully, we have a couple new faces on the team who are focussing on making the documentation a much more friendly place.

@JamesYeoman
Copy link
Author

Thanks for the response.

Digging deeper into the tauri codebase, I found that tauri uses std::sync::mpsc::channel to get data from spawned threads.

I get that it could be addressed by having a Tauri for people who are new to the rust ecosystem guide with things like that, but I personally think a better approach would be to handle the cross-thread communication in tauri itself, and make the functions async. Not only would that be more ergonomic for the end user, it would make the API more robust, as Tauri would be in control of communicating data between threads that it spawns as opposed to the consumers of Tauri.

Regardless, I think that if anyone were to make a Tauri for people who are new to the rust ecosystem guide, it would be tremendously helpful, as there seems to be a bunch of crates that are sort of expected that you know about and know that you need to use them (for example, wrapping state properties in mutexes so that you can modify them). Even things like pointing to existing reading for topics like Deref, moving, etc.

I learned the hard way that rust doesn't like unwrapping stuff inline. I was trying to traverse through a Result that contained an Option that contained a String, and the compiler wanted me to assign the intermediate Option to a variable to "keep it in scope". I still don't understand why, but it keeps the compiler happy. I just think having a guide of common roadblocks and how to overcome them would be nice. A large undertaking? Sure. But it would be very handy for greater adoption by people who want an Electron but significantly better™

@nothingismagick
Copy link
Member

Tauri for people who are new to the rust ecosystem is something @lucasfernog and I are working on right now.

@barbalex
Copy link

You guys have the bad fortune of building project so great, that it is sucking in web developers at a high rate. Web developers that need to learn / be educated in dealing with rust...

Love your work, guys!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: documentation Need to update the API documentation
Projects
None yet
Development

No branches or pull requests

4 participants