tsuzuki-takaaki / actix_yew

actix-web && yew sample

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Usage

# Start api server
% cd actix_api
% cargo run

# Start client
% cd yew_ui
% trunk serve --open

if you wanna post new post now, please do like this

curl -X POST -d '{"title": "This is a tweet", "body": "hello world"}' -H "Content-type: application/json" http://localhost:3000/posts

Search

prepared statement

serialize, deserialize(most important)

serde_json

yew

gloo_net: HTTP request library for WASM app

wasm_bindgen_futures

Debugging(yew)

CORS

classes!

yew tutorial

function_component macro(attribute)

struct component

You are currently reading about function components - the recommended way to write components when starting with Yew and when writing simple presentation logic.

There is a more advanced, but less accessible, way to write components - Struct components. They allow very detailed control, though you will not need that level of detail most of the time.

enum type alias

Callbacks

Event Listener

use_state(yew)

  log::debug!("{}", state);
  • console上に表示される

web_sys

target_unchecked_into()

creating node

oninput, onchange

InputEvent

Event

onchange vs oninput

  • onchange is the event that is triggerd after one event is done
  • oninput is the event that is triggered when typing into input area
  • so, you should use oninput if you would like to do like react onchange
  // ex
  let input_value = use_state(|| String::from(""));

  let handle_change = {
    let input_value = input_value.clone();
    Callback::from(move |e: web_sys::InputEvent| {
      let new_input_value: HtmlInputElement = e.target_unchecked_into();
      input_value.set(new_input_value.value());
    })
  };

UseStateHandle

  • UseStateHandle 構造体は set メソッドにより値を設定します。* 演算子により参照を外すことにより UseStateHandle 構造体より現在の状態を取得できます。
  • the value of use_state is wrapped by UseStateHandle.
  • *if you wanna access to the value wrapped UseStateHandle, you can use (dereference).

yew with css

trunk with css

  <link data-trunk rel="css" href="styles/index.css" />

Memo

About

actix-web && yew sample


Languages

Language:Rust 92.7%Language:CSS 5.0%Language:HTML 2.2%