Skip to content

Commit

Permalink
some more enum constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
tiye committed Oct 15, 2024
1 parent d8c8afe commit 1f65eb6
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 34 deletions.
42 changes: 12 additions & 30 deletions src/lib/node/diff.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub fn diff_tree[T](
let { name: name_old, effects: old_effects, tree: old_child } = right
if name == name_old {
let next_coord = coord.copy()
next_coord.push(RespoCoord::Comp(name))
next_coord.push(Comp(name))
diff_tree!(new_child, old_child, next_coord, dom_path, changes)
let skipped : @hashset.T[Int] = @hashset.new()
for idx, effect in effects {
Expand All @@ -25,17 +25,12 @@ pub fn diff_tree[T](
Effect(
~coord,
~dom_path,
effect_type=RespoEffectType::BeforeUpdate,
effect_type=BeforeUpdate,
skip_indexes=skipped,
),
)
changes.val.push(
Effect(
~coord,
~dom_path,
effect_type=RespoEffectType::Updated,
skip_indexes=skipped,
),
Effect(~coord, ~dom_path, effect_type=Updated, skip_indexes=skipped),
)
}
} else {
Expand Down Expand Up @@ -108,7 +103,7 @@ pub fn diff_tree[T](
BeforeUnmount,
changes,
)
changes.val.push(DomChange::ReplaceElement(~coord, ~dom_path, node=a))
changes.val.push(ReplaceElement(~coord, ~dom_path, node=a))
collect_effects_outside_in_as!(
new_tree,
coord,
Expand Down Expand Up @@ -185,9 +180,7 @@ fn diff_attrs[T](
}
}
if not(added.is_empty()) || not(removed.is_empty()) {
changes.val.push(
DomChange::ModifyAttrs(~coord, ~dom_path, set=added, unset=removed),
)
changes.val.push(ModifyAttrs(~coord, ~dom_path, set=added, unset=removed))
}
}

Expand Down Expand Up @@ -222,9 +215,7 @@ fn diff_style[T](
}
}
if not(added.is_empty()) || not(removed.is_empty()) {
changes.val.push(
DomChange::ModifyStyle(~coord, ~dom_path, set=added, unset=removed),
)
changes.val.push(ModifyStyle(~coord, ~dom_path, set=added, unset=removed))
}
}

Expand All @@ -243,7 +234,7 @@ fn diff_event[T, U](
)
if hashset_eq(new_keys, old_keys).not() {
changes.val.push(
DomChange::ModifyEvent(
ModifyEvent(
~coord,
~dom_path,
add=new_keys.difference(old_keys),
Expand All @@ -269,11 +260,7 @@ fn diff_children[T](
if old_tracking_pointer >= old_children.length() {
if not(operations.val.is_empty()) {
changes.val.push(
DomChange::ModifyChildren(
~coord,
~dom_path,
operations=operations.val,
),
ModifyChildren(~coord, ~dom_path, operations=operations.val),
)
}
return
Expand Down Expand Up @@ -436,7 +423,7 @@ pub fn collect_effects_inside_out_as[T](
changes : Ref[Array[DomChange[T]]]
) -> Unit!RespoCommonError {
match tree {
RespoNode::Component(left) => {
Component(left) => {
let { name, effects, tree } = left
let next_coord = coord.copy()
next_coord.push(Comp(name))
Expand All @@ -445,16 +432,11 @@ pub fn collect_effects_inside_out_as[T](
)
if not(effects.is_empty()) {
changes.val.push(
DomChange::Effect(
~coord,
~dom_path,
~effect_type,
skip_indexes=@hashset.new(),
),
Effect(~coord, ~dom_path, ~effect_type, skip_indexes=@hashset.new()),
)
}
}
RespoNode::Element(left) => {
Element(left) => {
let { children, .. } = left
let mut idx = 0
for pair in children.iter() {
Expand All @@ -469,7 +451,7 @@ pub fn collect_effects_inside_out_as[T](
idx += 1
}
}
RespoNode::Referenced(cell) =>
Referenced(cell) =>
collect_effects_inside_out_as!(
cell, coord, dom_path, effect_type, changes,
)
Expand Down
2 changes: 1 addition & 1 deletion src/main/panel.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn comp_panel(
// dispatch.run_state(&cursor, PanelState { content: value })?;
// }
match e {
@respo_node.RespoEvent::Input(~value, ..) =>
Input(~value, ..) =>
dispatch.run!(
StatesChange({ cursor, data: Some({ content: value }.to_json()) }),
)
Expand Down
2 changes: 1 addition & 1 deletion src/main/store.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fn ActionOp::default() -> ActionOp {
}

impl @respo_node.RespoAction for ActionOp with build_states_action(cursor, a) {
ActionOp::StatesChange({ cursor, data: a })
StatesChange({ cursor, data: a })
}

fn ActionOp::to_string(self : ActionOp) -> String {
Expand Down
2 changes: 1 addition & 1 deletion src/main/task.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn comp_task(
dispatch : @respo_node.DispatchFn[ActionOp]
) -> Unit!@respo_node.RespoCommonError {
@dom_ffi.log("TOGGLE TASK \{task_id}")
dispatch.run!(ActionOp::ToggleTask(task_id))
dispatch.run!(ToggleTask(task_id))
}
let on_input = fn(
e : @respo_node.RespoEvent,
Expand Down
2 changes: 1 addition & 1 deletion src/main/todolist.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fn comp_todolist(
)
}

// util::log!("{:?}", &tasks);
// @dom_ffi.log(tasks.to_string())

let on_hide = fn(
e : @respo_node.RespoEvent,
Expand Down

0 comments on commit 1f65eb6

Please sign in to comment.