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

Add feature: promised components #14

Closed
wants to merge 1 commit into from

Conversation

tylerbrostrom
Copy link

Hey @estrattonbailey! Really loving this library. It’s been a perfect "small-but-mighty" solve for a few projects of mine.

This PR effectively solves #7 but without baking in module.default resolution. Pass any Promise that resolves the value of a component call.

Though the API remains unchanged, I might consider this a breaking feature for the fact that mount is asynchronous. Might trip up some folks that call appInstance.emit() (or whatever) immediately after appInstance.mount().

I’ve updated tests and the readme. I thought grouping these readme additions alongside the explainer on the add method might make sense.

Let me know what you think! Cheers!

Feature Summary

Each passed component is now wrapped in a Promise.resolve, which has the following consequences:

  1. You can now pass promise-wrapped components to picoapp and appInstance.add.
  2. Picoapp requires that Promise be polyfilled for browsers that don’t support it.
  3. appInstance.mount() returns a Promise that resolves when all components have been successfully resolved and bound to the DOM.

On picoapp.mount(), each component is now wrapped in a Promise.resolve, which has the following consequences:

1. You can now asynchronously pass components to `picoapp` and `appInstance.add`.
1. Picoapp requires that `Promise` be polyfilled for browsers that don’t support it.
1. `appInstance.mount()` returns a `Promise` that resolves when all components have been successfully resolved and bound to the DOM.
@tylerbrostrom
Copy link
Author

Closing this in favor of #15 (same commit, different branch).

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.

1 participant