feat(slhx): prefer render methods for views
Move view rendering onto Slot::render and KeyedSlot append/prepend/replace extension methods, leaving explicit text/html methods for non-view escape hatches. req: codegen/002 req: view/001
This commit is contained in:
+3
-10
@@ -777,13 +777,6 @@ impl<T> Slot<T> {
|
||||
self.id
|
||||
}
|
||||
|
||||
pub fn render(self, value: T) -> Effect
|
||||
where
|
||||
T: ToString,
|
||||
{
|
||||
self.text(value)
|
||||
}
|
||||
|
||||
pub fn text(self, value: impl ToString) -> Effect {
|
||||
Effect::Put {
|
||||
target: ResourceRef::unscoped(self.id),
|
||||
@@ -834,7 +827,7 @@ where
|
||||
self.id
|
||||
}
|
||||
|
||||
pub fn append(self, key: K, value: T) -> Effect
|
||||
pub fn append_text(self, key: K, value: T) -> Effect
|
||||
where
|
||||
T: ToString,
|
||||
{
|
||||
@@ -845,7 +838,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
pub fn prepend(self, key: K, value: T) -> Effect
|
||||
pub fn prepend_text(self, key: K, value: T) -> Effect
|
||||
where
|
||||
T: ToString,
|
||||
{
|
||||
@@ -856,7 +849,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
pub fn replace(self, key: K, value: T) -> Effect
|
||||
pub fn replace_text(self, key: K, value: T) -> Effect
|
||||
where
|
||||
T: ToString,
|
||||
{
|
||||
|
||||
@@ -11,9 +11,9 @@ fn effect_batch_wire_round_trips() {
|
||||
let user = Atom::<String>::new(3);
|
||||
|
||||
let batch = (
|
||||
count.render(2),
|
||||
todos.append(7, String::from("Buy milk")),
|
||||
todos.replace(7, String::from("Buy oat milk")),
|
||||
count.text(2),
|
||||
todos.append_text(7, String::from("Buy milk")),
|
||||
todos.replace_text(7, String::from("Buy oat milk")),
|
||||
user.set("Ada"),
|
||||
navigate("/todos"),
|
||||
event("toast", "Saved"),
|
||||
@@ -32,7 +32,7 @@ fn effect_batch_wire_round_trips() {
|
||||
fn keyed_slot_replace_uses_scoped_resource_ref() {
|
||||
let todos = KeyedSlot::<u64, String>::new(9);
|
||||
// req: codegen/002
|
||||
let effect = todos.replace(12, String::from("done"));
|
||||
let effect = todos.replace_text(12, String::from("done"));
|
||||
|
||||
let Effect::Put { target, payload } = effect else {
|
||||
panic!("expected Put");
|
||||
|
||||
Reference in New Issue
Block a user