example_app.rs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. //! Example App
  2. //! --------------
  3. //!
  4. //! This example shows how to use the cross-platform abilities of dioxus to generate everything a dioxus app might need.
  5. //! All of your apps will look like this.
  6. //!
  7. //! cargo run --features dioxus/static
  8. use std::u32;
  9. use dioxus::prelude::Context;
  10. // #[allow(unused_lifetimes)]
  11. #[derive(Debug, PartialEq, Hash)]
  12. struct Pool<'a> {
  13. a: u32,
  14. b: &'a str,
  15. }
  16. struct UserData {}
  17. type Query<In, Out> = fn(&Pool, In) -> Result<Out, ()>;
  18. // type Query<In, Out> = fn(&Pool, In) -> Out;
  19. static GET_USER: Query<String, Vec<UserData>> = |pool, name| {
  20. //
  21. let b = Ok(())?;
  22. let b = Ok(())?;
  23. let b = Ok(())?;
  24. let b = Ok(())?;
  25. let b = Ok(())?;
  26. let b = Ok(())?;
  27. todo!()
  28. };
  29. static SET_USER: Query<String, Vec<UserData>> = |pool, name| {
  30. //
  31. todo!()
  32. };
  33. fn main() {
  34. // // returns a future
  35. // let user_data = use_db(&ctx, GET_USER, || "Bill");
  36. // use_try_suspense(&ctx, async move {
  37. // match user_data.await? {
  38. // Ok() => {}
  39. // Err(err) => {}
  40. // }
  41. // })
  42. // }
  43. // fn use_try_suspense(ctx: &Context<()>) {
  44. // let c: Result<(), ()> = {
  45. // // let b = Ok(());
  46. // // b?
  47. // };
  48. }
  49. mod launches {
  50. #[cfg(feature = "wasm")]
  51. fn launch() {
  52. // launch the wasm_rednerer
  53. }
  54. #[cfg(feature = "static")]
  55. fn launch() {
  56. // render the tree to text
  57. }
  58. // #[cfg(features = "server")]
  59. // fn launch() {
  60. // // launch the app
  61. // }
  62. // #[cfg(features = "liveview")]
  63. // fn launch() {
  64. // // launch the app
  65. // }
  66. // #[cfg(features = "desktop")]
  67. // fn launch() {
  68. // // launch the app
  69. // }
  70. // #[cfg(features = "android")]
  71. // fn launch() {
  72. // // launch a simulator in dev mode
  73. // }
  74. // #[cfg(features = "ios")]
  75. // fn launch() {
  76. // // launch a simulator in dev mode
  77. // }
  78. }