Leptos Server Functions

  Рет қаралды 8,997

chris biscardi

chris biscardi

Күн бұрын

Пікірлер: 28
@jamese.spivak4170
@jamese.spivak4170 Жыл бұрын
This is really cool. I love axum. Leptos is looking pretty appealing now. I hope they can integrate a more native axum into leptos!
@chrisbiscardi
@chrisbiscardi Жыл бұрын
I don't know if they will. My understanding is that the current API aligns well with the project author's take on how much macro magic should exist. *however* the project is structured in such a way that if you wanted to (and I have experiments locally doing this) you could write your own macro that code-gen'd different code meant to be used in a different way. So even if Leptos doesn't get deeper actix/axum integrations, its still entirely reasonable and possible to extend Leptos with an additional crate.
@theJamieBenShaw
@theJamieBenShaw Жыл бұрын
Totally agree, I felt similar with leptos:For and leptos:MultiAction and especially the MultiActionForm, I just wanted to write reactive rust code but some of the abstractions made that feel more difficult that I wanted it to be. The create_server_multi_action lends itself to be used with the MultiActionForm, but when I wanted to change the behaviour of that input I was stuck trying to figure out how all this abstraction actually glued together. In that todo example, I simply wanted to clear the input field when a new todo was added but for the life of me I couldn't see how to to do that MultiActionForm. If it was basic signals, that would seem more straight forward but then how do those integrate with create_server_multi_action etc I do not know. Disclaimer: Still playing around with Leptos and Rust so there may well be obvious solutions to the above issue I had, having a blast but learning curves are hard :)
@romanstingler435
@romanstingler435 Жыл бұрын
LEPTOS is spreading BLAZINGLY FAST
@3dwebdev
@3dwebdev 8 ай бұрын
You should consider adding a youtube "thanks" button so people can give you money on youtube. I'm sure there's people who are happy to give you money for the help you've given.
@echobucket
@echobucket Жыл бұрын
It's still early days into people trying to do this. I figure leptos is just the first framework to try this in Rust. I feel like there will be others that may handle this differently
@iowolf
@iowolf Жыл бұрын
I love your work
@evanhines2490
@evanhines2490 Жыл бұрын
How do I access a form of global state (Database threadpool) inside a server function? I guess my main question is how is the db() function that you're calling defined? Do you use a lazy_static db pool? Is it possible to pass the handle through the scope similar to Axum's state?
@chrisbiscardi
@chrisbiscardi Жыл бұрын
check out the axum sessions example in the leptos github repo and you'll find an example of providing this information via context. You need to use some additional bootstrapping functions to prepare the context so that you can access it via context in the server functions
@irlshrek
@irlshrek Жыл бұрын
Love this! I think I'll be having fun with leptos
@echobucket
@echobucket Жыл бұрын
So Next.JS's approach was to basically tie themselves to express on the backend (I think it's express under the hood, it's hard to tell) , so you have a unified approach to server side API functions.... Leptos is trying to build this adapter based approach that doesn't tie yourself to Axum or Rocket or whatever. But that of course leads to complexity....
@chrisbiscardi
@chrisbiscardi Жыл бұрын
yeah, it's basically all just different tradeoffs. Leptos is pretty usable as it currently stands, so I'm not worried about it at all.
@thanhdatvo0
@thanhdatvo0 Жыл бұрын
This is a great explanation! Question: how could I open [EXPANSION].rs file in vscode?
@chrisbiscardi
@chrisbiscardi Жыл бұрын
rust-analyzer has a command called "expand macro recursively" that will do that for you
@thanhdatvo0
@thanhdatvo0 Жыл бұрын
@@chrisbiscardi thank you!
@biomorphic
@biomorphic Жыл бұрын
I see the view code is in line. Isn't possible to write the view in a separate file with a different extension? Because this remember me PHP when we still didn't have template engines.
@Leeway4434
@Leeway4434 Жыл бұрын
If the template is not written in rust, you wouldn't be able to get help from the compiler type checking
@d.sherman8563
@d.sherman8563 Жыл бұрын
The view is a rust macro, which is basically a custom fully type checked templating language. It might look like html but it’s not, kind of like jsx.
@mannycalavera121
@mannycalavera121 Жыл бұрын
I had a quick look but there's very few docs?
@chrisbiscardi
@chrisbiscardi Жыл бұрын
they had their first release on crates.io very recently. The docs are in-progress and will be more complete soon.
@GlennPierce
@GlennPierce Жыл бұрын
If you had a EditTodo server function thats takes a todo id as a param and returns a Todo item. How would you call that from a Component. Ie #[component] fn TodoEdit() -> impl IntoView { let params = use_params_map(); let todo_id = move || { params.with(|params| params.get("todo_id").cloned()) }; // Call server function get_todo(id) to populate edit form below ? ...
@chrisbiscardi
@chrisbiscardi Жыл бұрын
If you're trying to load data, you need to look into Resources and Suspense components along with create_server_action. There's an example in the leptos repo here: github.com/leptos-rs/leptos/blob/6014a70d0def869f12282d2df8b6c442a012964d/examples/todo_app_sqlite_axum/src/todo.rs#L117-L125
@GlennPierce
@GlennPierce Жыл бұрын
Thanks That is the example I have been following to learn. I then wanted to basically extend the example to include a todo edit form that would be just the same as the add form (MultiActionForm) but with all the fields populated from a specific todo from a server function. The the form would update the todo.@@chrisbiscardi
@jaysistar2711
@jaysistar2711 Жыл бұрын
Hello Chris. This comment will probably be flagged for having a link in it, but i found a video about HarperDB that show everything running locally. kzbin.info/www/bejne/a6G5cmqIaZ2CmpI
@chrisbiscardi
@chrisbiscardi Жыл бұрын
Surprisingly not flagged! Maybe because it's a KZbin link. I'll drop it into my queue to watch
@jaysistar2711
@jaysistar2711 Жыл бұрын
@@chrisbiscardi Maybe so. Also, it's useful to know that to get HarperDB Studio (the web admin GUI) you have to set the environment variable LOCALSTUDIO_ENABLED=true
@jaysistar2711
@jaysistar2711 Жыл бұрын
I'm making a multiplayer game with Bevy. I'm also trying to extend the OpenXR support to use WebXR as well for both a native build and web build (maybe only for a demo, but maybe more), and I'm on the fence between HarperDB and SurrrealDB for the backend API's database. I do want to keep some data cached on the client side, but I want to be notified when it changes. HarperDB and SurrealDB both have a "watch" or "live" query. I think that HarperDB's may be more limited (only watch a table, not really a "query"), but it has the advantage of being available now, where SurrealDB only has it as a promised "future" feature. My first thought was use Meteor, but because that only works in the browser, that would take just as much work to integrate. I was hoping that you would make a video (or a few) comparing these 2 databases that would help to bias my opinion toward one of them.
@shoulderstack5527
@shoulderstack5527 Жыл бұрын
This is starting to sound like hand coding the whole stack in C would actually be easier. 😁 The whole industry is going crazy, unless it's me that's going crazy...
SolidJS in Rust with Sycamore
7:22
chris biscardi
Рет қаралды 7 М.
Heap profiling Rust programs with DHAT
16:37
chris biscardi
Рет қаралды 10 М.
진짜✅ 아님 가짜❌???
0:21
승비니 Seungbini
Рет қаралды 10 МЛН
УЛИЧНЫЕ МУЗЫКАНТЫ В СОЧИ 🤘🏻
0:33
РОК ЗАВОД
Рет қаралды 7 МЛН
Жездуха 41-серия
36:26
Million Show
Рет қаралды 5 МЛН
How to Build Beautiful Gauges in LVGL Using Meters
34:03
Garage Tinkering
Рет қаралды 2,7 М.
The Truth about Rust/WebAssembly Performance
29:47
Greg Johnston
Рет қаралды 189 М.
Build A Full Stack Chatbot in Rust (feat. Leptos & Rustformers)
43:40
Code to the Moon
Рет қаралды 174 М.
Generic Traits, Impls, and Slices in Rustlang
18:05
chris biscardi
Рет қаралды 11 М.
Actix Web vs. Axum: Is One a Clear Winner?
8:59
OptiCode
Рет қаралды 3,1 М.
Fine Grained Reactivity with Leptos, Rust, and WASM
17:21
chris biscardi
Рет қаралды 18 М.
Building Web APIs With Rust and Axum - An Introduction
47:16
Rainer Stropek
Рет қаралды 20 М.
SQLx is my favorite PostgreSQL driver to use with Rust.
9:47
Dreams of Code
Рет қаралды 59 М.
Why Learn HTMX?? | Prime Reacts
21:29
ThePrimeTime
Рет қаралды 124 М.
Smarter Programming in Rust: Master 'move' Now!
9:06
Flo Woelki
Рет қаралды 5 М.
진짜✅ 아님 가짜❌???
0:21
승비니 Seungbini
Рет қаралды 10 МЛН