Feat: updates to docs, extension

This commit is contained in:
Jonathan Kelley committed 2021-01-29 11:57:52 -05:00
1 parent 2e626aea51
commit a2406b33d6
25 files changed
+917 -508

No files matched your search

+20
View File
@@ -20,15 +20,27 @@ anyhow = "*"
async-std = { version = "1.9.0", features = ["attributes"] }
tide = { version = "0.15.0" }
# For the livewview example
tide-websockets = "0.1.0"
serde_millis = "0.1"
serde_json = "1"
serde = { version = "1", features = ['derive'] }
# For the doc generator
pulldown-cmark = { version = "0.8.0", default-features = false }
dioxus-webview = { path = "../packages/webview", version = "0.0.0" }
dioxus-hooks = { path = "../packages/hooks", version = "0.0.0" }
# Shared functionality is done as a lib
[lib]
path = "common.rs"
# ================================
# Examples are manually keyed in
# ================================
[[example]]
path = "hello_web.rs"
name = "hello_web"
@@ -52,3 +64,11 @@ name = "fc_macro"
[[example]]
path = "webview.rs"
name = "webview"
[[example]]
path = "blah.rs"
name = "blah"
[[example]]
path = "live.rs"
name = "live"
+9
View File
@@ -0,0 +1,9 @@
use dioxus::prelude::*;
fn main() {
let g = html! {
<div>
<style> </style>
</div>
};
}
+65
View File
@@ -0,0 +1,65 @@
use dioxus::prelude::*;
use tide::{with_state, Request};
use tide_websockets::{WebSocket, WebSocketConnection};
fn main() {
let mut g = Context { props: &() };
LiveComponent(&mut g);
}
#[cfg(not(target_arch = "wasm32"))]
async fn server() -> tide::Result<()> {
// Build the API
let mut app = tide::with_state(());
app.at("/app").get(WebSocket::new(live_handler));
// Launch the server
app.listen("127.0.0.1:8080").await?;
Ok(())
}
async fn live_handler(req: Request<()>, stream: WebSocketConnection) -> tide::Result<()> {
Ok(())
}
static LiveComponent: FC<()> = |ctx| {
use_live_component(
ctx,
#[cfg(target_arch = "wasm32")]
|| {
// Always wait on the context's live component API
// suspend the component until this promise arrives, or fall back
let g = &LiveComponent;
html! {
<div>
{"Hello world!"}
</div>
}
},
#[cfg(not(target_arch = "wasm32"))]
|| {
// actually use the code originally specified in the component
// this gives use the function pointer. We don't necessarily get to hash the same pointer between two binaries
// Some key will need to be made, likely based on the function parameter
let g = &LiveComponent;
html! {
<div>
{"Hello world!"}
</div>
}
},
)
};
/// This hooks connects with the LiveContext at the top of the app.
fn use_live_component<T>(ctx: &mut Context<T>, b: fn() -> VNode) -> VNode {
todo!()
}
/// LiveContext is a special, limited form of the context api that disallows the "Context API"
/// Its purpose is to shield the original Context where calls to use_context will fail. Instead of panicing and confusing
/// users, we simply disallow usage of "use_context" and "childen". In effect, only serialiable props can be allowed.
///
/// In the future, we might try to lift these restrictions (esp children since they are virtual) but are limited via the web connection
struct LiveContext {}
+2
View File
@@ -26,5 +26,7 @@ fn main() {
}
});
let f = 10_i32;
println!("hello {}", f);
app.launch(());
}