Skip to content

Commit

Permalink
Fix the goose.
Browse files Browse the repository at this point in the history
  • Loading branch information
ntoll committed Feb 14, 2024
1 parent 0165cb2 commit c9c5b48
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/invent/ui/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,13 @@ def __set__(self, obj, value):
if isinstance(value, from_datastore):

def reactor(message, key=value.key):
if message.key == key:
if message._subject == key:
setattr(
obj, self.private_name, self.validate(message.value)
)
obj.render()

invent.subscribe(reactor, to_channel="datastore", when="store")
invent.subscribe(reactor, to_channel="store-data", when=value.key)
value = invent.datastore.get(value.key)
setattr(obj, self.private_name, self.validate(value))

Expand Down
4 changes: 2 additions & 2 deletions static/goose.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
</head>
<body>
<div style="margin: auto; width: 85%">
<script type="mpy" src="./static/goosey.py"
config="./static/mpy-settings.json"></script>
<script type="mpy" src="/static/goosey.py"
config="/static/mpy-settings.json"></script>
</div>
</body>
</html>
8 changes: 4 additions & 4 deletions static/goosey.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import invent
from invent.ui import Button, Image, from_datastore

invent.set_media_root("static")
invent.set_media_root("/static")
invent.datastore.update({
"number_of_honks": 0,
"number_of_oinks": 0,
Expand Down Expand Up @@ -81,9 +81,9 @@ def move_page(message):


# Pubsub (???)
invent.pubsub.subscribe(make_honk, to_channel="honk", when=["press", "touch"])
invent.pubsub.subscribe(make_oink, to_channel="oink", when=["press", "touch"])
invent.pubsub.subscribe(move_page, to_channel="navigate", when=["press",])
invent.subscribe(make_honk, to_channel="honk", when=["press", "touch"])
invent.subscribe(make_oink, to_channel="oink", when=["press", "touch"])
invent.subscribe(move_page, to_channel="navigate", when=["press",])


# GO!
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ def test_widget_init_defaults():
assert len(w.id[7:]) == 10
# The default position is top left.
assert w.position == "TOP-LEFT"
# The default pubsub channel for widget related messages is the same as
# The default channel for widget related messages is the same as
# the widget's id.
assert w.channel == w.id

Expand Down

0 comments on commit c9c5b48

Please sign in to comment.