Skip to content

Commit 5e26adb

Browse files
authored
Merge pull request #1 from Termina/update
update respo 0.0.33
2 parents d53d385 + 68c0111 commit 5e26adb

4 files changed

Lines changed: 19 additions & 37 deletions

File tree

moon.mod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "respo/app",
33
"version": "0.1.0",
44
"deps": {
5-
"tiye/respo": "0.0.32",
5+
"tiye/respo": "0.0.33",
66
"tiye/dom-ffi": "0.0.9"
77
},
88
"readme": "README.md",

src/container.mbt

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
///|
2-
typealias @respo_node.(RespoEvent, RespoNode, DispatchFn, RespoCommonError)
2+
typealias @respo_node.RespoNode
33

44
///|
5-
fnalias @respo_node.(text_node, textarea, declare_static_style)
5+
fnalias @respo_node.(textarea, static_style)
66

77
///|
88
fnalias @respo.ui_textarea
@@ -22,38 +22,30 @@ fn comp_container(states : @respo.RespoStatesTree) -> RespoNode[ActionOp] {
2222
class_list=[ui_textarea, style_textbox],
2323
placeholder="Question",
2424
value=state.draft,
25-
event=Map::of([
26-
(
27-
Input,
28-
fn(e, dispatch) {
29-
if e is Input(value~, ..) {
30-
dispatch.set_state!(cursor, ContainerState::{ draft: value })
31-
}
32-
},
33-
),
34-
(
35-
Keydown,
36-
fn(e, dispatch) {
37-
if e is Keyboard(key_code~, meta_key~, ..) {
38-
if key_code == 13 && meta_key {
39-
ask_gemini(state.draft)
40-
}
41-
}
42-
},
43-
),
44-
]),
25+
on_input=fn(e, dispatch) {
26+
if e is Input(value~, ..) {
27+
dispatch.set_state!(cursor, ContainerState::{ draft: value })
28+
}
29+
},
30+
on_keydown=fn(e, _dispatch) {
31+
if e is Keyboard(key_code~, meta_key~, ..) {
32+
if key_code == 13 && meta_key {
33+
ask_gemini(state.draft)
34+
}
35+
}
36+
},
4537
),
4638
button(
4739
inner_text="Ask",
4840
class_name=ui_button,
4941
style=respo_style(margin=4 |> Px),
50-
event={}..set(Click, fn(e, dispatch) { ask_gemini(state.draft) }),
42+
on_click=fn(_e, _dispatch) { ask_gemini(state.draft) },
5143
),
5244
]),
5345
])
5446
}
5547

5648
///|
57-
let style_textbox : String = declare_static_style([
49+
let style_textbox : String = static_style([
5850
("&", respo_style(width=600 |> Px, height=160 |> Px)),
5951
])

src/main.mbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
fnalias @respo.(ui_global, ui_button)
33

44
///|
5-
fnalias @respo_node.(div, span, button, respo_style)
5+
fnalias @respo_node.(div, button, respo_style)
66

77
///|
88
let app_store_key : String = "mbt-workflow"

src/store.mbt

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
///|
22
struct Store {
3-
mut counted : Int
3+
counted : Int
44
tasks : Array[Task]
55
states : @respo.RespoStatesTree
66
} derive(ToJson, @json.FromJson)
@@ -21,9 +21,6 @@ struct Task {
2121
///|
2222
enum ActionOp {
2323
StatesChange(@respo.RespoUpdateState)
24-
Increment
25-
Decrement
26-
IncTwice
2724
}
2825

2926
///|
@@ -36,10 +33,6 @@ impl Show for ActionOp with output(self, logger) -> Unit {
3633
let s = match self {
3734
StatesChange(states) =>
3835
"StatesChange(\{states.cursor} \{states.data.to_json()})"
39-
// Intent(_intent) => "Intent(...)"
40-
Increment => "Increment"
41-
Decrement => "Decrement"
42-
IncTwice => "IncTwice"
4336
}
4437
logger.write_string(s)
4538
}
@@ -52,10 +45,7 @@ fn get_states(self : Store) -> @respo.RespoStatesTree {
5245
///| TODO mutation might break memoization in future
5346
fn update(self : Store, op : ActionOp) -> Unit {
5447
match op {
55-
Increment => self.counted += 1
5648
StatesChange(states) => self.states.set_in_mut(states)
57-
Decrement => self.counted -= 1
58-
_ => ()
5949
}
6050
}
6151

0 commit comments

Comments
 (0)