Adding server url page #23
No reviewers
Labels
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Blocks
#30 Integrate Storybook and ts-rs
puregarlic/microclimate
Reference
puregarlic/microclimate!23
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "issues/10-server-url"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #10
AppData/Roaming/systems.graham.microclimate/config.jsonwill need to add a button in settings or maybe just in layout temporarily to change server url18117f25d1to570c3d24a0"Calling gRPC procedures to connect commit" isn't real, look at the Commits tab for the actual up-to-date commit list
@ -2,0 +23,4 @@const navigate = useNavigate();const [url, setUrl] = useState("");const { data, error, isLoading } = useSWR("get_server_url", fetcher);@ -2,0 +25,4 @@const { data, error, isLoading } = useSWR("get_server_url", fetcher);// console.log(`"${data}"`, error, isLoading);Delete
0d8400821ftoedbf32f37fJust a few things to cleanup, in addition to the
anyhowcomments. I've already discussedts-rswith @seb, so at the very least we'll want to get that in for complicated commands--though it's not necessarily required for your simple commands at this time though. I'm open to discussion as to how to proceed, but again, my perspective is that there's no time like the present to be thorough about errors.@ -1,1 +6,4 @@export default function Layout() {const navigate = useNavigate();const handleOnClick = async (e: React.SyntheticEvent) => {This is a good candidate for a
clientAction.@ -2,0 +32,4 @@const navigate = useNavigate();const [url, setUrl] = useState("");const handleSubmit = async (e: React.SyntheticEvent) => {This should be a
clientActionas well@ -28,2 +28,4 @@tonic-prost = "*"tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] }tauri-plugin-store = "2"anyhow = "1.0.101"Not gonna lie... Not a huge fan of
anyhow. I know it's convenient, but we should start on the right foot of handling our errors correctly.I know with Tauri commands especially, this is annoying, because the error result needs to derive serde's
Serialize. This means:Errorenum that encompasses all of the possible failures, and thenI used ts-rs in
petiteto make this easier. At the module level, you can define a custom error enum that will handle any un-derived errors into strings, with added metadata to describe the practical effect of the error. Then, because that enum isSerialize-able, ts-rs can generate a type you can use in JS land to check for different error conditions. And also--you can now get strongly-typed objects from structs for command payloads.I know it feels a bit excessive, but I would really us rather get in the habit of handling these errors the right way sooner rather than later.
Yeah makes sense, I'll remove anyhow, but custom errors always seem like such a huge waste of time. In the end I've never seen use of custom error types. I always just need the message, and the stack trace. And I hate the effort of elaborating all these different categories of errors and then their use cases just seem unusable because on the receiving end you want to split out error handling based on the category of error but end up doing basically the same thing. After all, what can you really do when there's an error? it's not like the client is gonna fix that.
Griping aside, since tauri::command doesn't even allow anyhow errors it's definitely a non-starter.
@ -12,0 +24,4 @@Ok(())}).invoke_handler(tauri::generate_handler![greet,We can probably yoink this guy now
Can we merge #24 in here prior to merging to main?
@seb wrote in #23 (comment):
I'm for this. You'll need to coordinate with @tepichord.
4ddf795f59to79a1ca3d88LGTM
54a371846dto4430992f0d