Closed dphfox closed 2 months ago
One gotcha here is merge conflict handling. It's entirely possible that the outer scope defines some method with the same name as one which the inner scope would like to have. scoped
throws an error on merge conflicts, because it's likely programmer error there. However, in this case, it would be forming an implicit contract with the owner of the outer scope that they don't use methods of that name. This breaks encapsulation, so I would suggest that merge conflict errors should only occur for methods that are passed in simultaneously, not between an inner scope's method definitions and an outer scope's method definitions.
Implemented - just need to write docs.
deriveScope
andinnerScope
should accept extra arguments to add additional methods to the newly created scope.This is useful because many components already implement what is effectively an inner scope already, but have to use
scoped
for the task because the other functions do not allow for a changed set of methods.If implemented, the above could could be reduced to a single call:
This notably means that it's impossible to forget to add the inner scope to the outer scope, reducing the surface area for bugs.