| Class: Make | ./src/peak/binding/once.py | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
Make(recipe)' - Construct a value and cache itUsage examples:
class MyComponent(binding.Component):
# this makes a new dictionary in each MyComponent instance
aDict = binding.Make(dict)
# this makes an instance of 'thing.Thing' in each MyComponent
aThing = binding.Make("things.Thing")
# 1-argument functions are called with the MyComponent instance
someAttr = binding.Make(lamdba self: self.otherAttr * 2)
# Types and no-argument functions are just called
otherAttr = binding.Make(lambda: 42)
XXX need more docs for adaptations to 'IRecipe
|