Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass initApp() params as object #52

Merged
merged 1 commit into from
Dec 17, 2023
Merged

Conversation

mbland
Copy link
Owner

@mbland mbland commented Dec 17, 2023

Now all parameters that initApp() may pass through to each individual component's init() function are bundled into a single object.

Other small but significant changes:

  • Removes window and document from the parameter list for now, as there's no components that need to inject them.

  • Sets up a list of components in initApp() so that it can call each component's init() via forEach(). This eliminates the need to add a new line for each init() call for each added component.

  • Sets initApp() to run only once on DOMContentLoaded.

  • Removes the now unused fragment() test helper (should've been part of commit 5f2a917 from Have StringCalculatorPage use host document #51).


While adding the Calculator component, it became apparent that adding more params to main.js and initApp() to pass through to init() was becoming unwieldy. This solution makes future extension easier and the code cleaner while decoupling component initializer signatures from one another.

Now all parameters that initApp() may pass through to each individual
component's init() function are bundled into a single object.

Other small but significant changes:

- Removes window and document from the parameter list for now, as
  there's no components that need to inject them.

- Sets up a list of components in initApp() so that it can call each
  component's init() via forEach(). This eliminates the need to add a
  new line for each init() call for each added component.

- Sets initApp() to run only once on DOMContentLoaded.

- Removes the now unused fragment() test helper (should've been part of
  commit 5f2a917 from #51).

---

While adding the Calculator component, it became apparent that adding
more params to main.js and initApp() to pass through to init() was
becoming unwieldy. This solution makes future extension easier and the
code cleaner while decoupling component initializer signatures from one
another.
@mbland mbland self-assigned this Dec 17, 2023
@mbland mbland merged commit 051bde7 into main Dec 17, 2023
3 checks passed
@mbland mbland deleted the pass-initapp-params-as-object branch December 17, 2023 00:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant