Move the history provider into the context (#3048)
* move history providers into a separate crate * start moving route providers into the renderers * clean up intoroutable * remove into routable * fix router tests * Provide history providers in each renderer * implement nested routers * move the lens out of the history crate * re-export dioxus history trait in the prelude * also re-export the history function * fix history doctests * some light cleanups --------- Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
This commit is contained in:
1 parent
e5a1a62644
commit
281087469a
48 files changed
+875
-1419
No files matched your search
@@ -1,5 +1,6 @@
|
||||
use dioxus_core::ScopeId;
|
||||
use dioxus_document::{Document, Eval, EvalError, Evaluator};
|
||||
use dioxus_history::History;
|
||||
use generational_box::{AnyStorage, GenerationalBox, UnsyncStorage};
|
||||
use js_sys::Function;
|
||||
use serde::Serialize;
|
||||
@@ -9,6 +10,8 @@ use std::pin::Pin;
|
||||
use std::{rc::Rc, str::FromStr};
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
use crate::history::WebHistory;
|
||||
|
||||
#[wasm_bindgen::prelude::wasm_bindgen]
|
||||
pub struct JSOwner {
|
||||
_owner: Box<dyn std::any::Any>,
|
||||
@@ -53,12 +56,16 @@ extern "C" {
|
||||
pub async fn rust_recv(this: &WeakDioxusChannel) -> wasm_bindgen::JsValue;
|
||||
}
|
||||
|
||||
/// Provides the WebEvalProvider through [`ScopeId::provide_context`].
|
||||
/// Provides the Document through [`ScopeId::provide_context`].
|
||||
pub fn init_document() {
|
||||
let provider: Rc<dyn Document> = Rc::new(WebDocument);
|
||||
if ScopeId::ROOT.has_context::<Rc<dyn Document>>().is_none() {
|
||||
ScopeId::ROOT.provide_context(provider);
|
||||
}
|
||||
let history_provider: Rc<dyn History> = Rc::new(WebHistory::default());
|
||||
if ScopeId::ROOT.has_context::<Rc<dyn History>>().is_none() {
|
||||
ScopeId::ROOT.provide_context(history_provider);
|
||||
}
|
||||
}
|
||||
|
||||
/// The web-target's document provider.
|
||||
|
||||
Reference in new issue
Block a user