158 days ago · 7 min read1447 words · Tech · hide · Fediverse post

Hello, loves! I think we can do without the info object entirely. Let’s find out. Bear takes a nibble but I think we’re OK. It occurred to me that we can probably put an item’s extra variables right in the procedure that creates a CombinedContent item, and reference them using nonlocal inside the callbacks. It turns out that our existing callback test actually demonstrates the idea: def test_subscriptions(self): count = 0 def increment(*, content, state): nonlocal count print('counting') count += 1 sub = Subscription(event='do_it', caller_id='', callback=increment) content = CombinedContent( name='item', resources = [], scale=1, subs=[sub] ) content.run(self) self.pub_sub.publish('do_it', caller_id='xxx', content=self, state=1) assert count == 1 We declare the variable in the setup, reference it via nonlocal in the callback function, and check it back in the test. And it works, which isn’t really much of a surprise. But it does mean that we don’t need the info feature. We’ll keep it…

Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town