-
Notifications
You must be signed in to change notification settings - Fork 295
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refac: DRY up New, reuse *All methods, delete modules slice (#1258)
The pattern we appear to have for Fx operations (Provide, Invoke, etc.) take the form: func (*module) thing(t thing) func (m *module) thingAll() { // perform module-local version of operation for _, t := range m.things { m.thing(t) } // recurse into children for _, m := range m.modules { m.${operation}All() } } This means that the following two are equivalent: // 1 for _, m := range app.modules { m.thingAll() } // 2 app.root.thingAll() Except (2) is DRYer. This cleans up New by relying on root-level `*All` methods instead of manually iterating over modules. Making this change also highlighted that 'app.modules' only ever has one entry: the root module. So we can delete that field from App as well. Finally, this also renames: constructAllCustomLoggers -> installAllEventLoggers constructCustomLogger -> installEventLogger executeInvokes -> invokeAll executeInvoke -> invoke
- Loading branch information
Showing
2 changed files
with
14 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters