Simplify by resuing (copy-paste) a component from newsticker.
+/* Components (reuse from newsticker.calvin) */
+component PrintFormattedList(item_fmt) list -> {
+ """
+ Iterate over a list and print each item (dictionary) formatted according to item_fmt.
+
+ Inputs:
+ list : a list of items in JSON format
+ """
+ commitlist : json.Items()
+ fmt: text.Format(fmt=item_fmt)
+ printout : io.Print()
+
+ .list > commitlist.list
+ commitlist.item > fmt.dict
+ fmt.text > printout.token
+}
+
+
/* Actors */
tick : std.Trigger(tick=3600.0, data="http://api.open-notify.org/astros.json")
iip : flow.Init(data="nothing")
client : net.HTTPGet()
cmp : std.Compare(op="=")
sel : flow.Select()
-status : io.Print()
to_json: json.FromString()
get_list : json.GetValue()
-itemize: json.Items()
-format: text.Format(fmt="{name}, {craft}")
+print : PrintFormattedList(item_fmt="{name}, {craft}")
/* Connections */
@@ -26,6 +42,4 @@ sel.case_false > iip.in
sel.case_false > to_json.string
to_json.data > get_list.container
"people" > get_list.key
-get_list.value > itemize.list
-itemize.item > format.dict
-format.text > status.token
+get_list.value > print.list
