1 hour ago · Tech · hide · 0 comments

Hello, loves! I’m just gonna go for it. If it works, I’ll claim it, if not, there’s always reset. It works! Wow! I figure we’ll wind up with a view maker and a view. One issue that I see is the subscriptions. As things stand, a subscription is a function that the PubSub calls. Ideally, we might like to do the subscriptions in the view maker, but have them execute in the view itself. Let’s try that in a test. def subscribe_someone_else(self): pub_sub = PubSub() view = FakeView() pub_sub.subscribe('event', '', view.on_event) assert view.called is False pub_sub.publish('event', '') assert view.called is True class FakeView: def __init__(self): self.called = False def on_event(self, event): self.called = True So that test shows that we have subscribed the on_event method of FakeView to the ‘event’, as one would hope. Our subscriptions are currently a bit tricky: class DungeonView: def subscribe_to_remove_content(self, pub_sub): def callback(*, pub_sub, content):…

No comments yet. Log in to reply on the Fediverse. Comments will appear here.